|
1 | 1 | """Test QtGui."""
|
| 2 | +import os |
| 3 | +import sys |
| 4 | + |
2 | 5 | import pytest
|
3 | 6 |
|
4 | 7 | from qtpy import PYQT5, PYQT_VERSION, QtGui
|
5 | 8 |
|
6 | 9 |
|
7 |
| -def test_qdrag_functions(): |
| 10 | +@pytest.mark.skipif(sys.platform.startswith('linux') and os.environ.get('USE_CONDA', 'No') == 'No', |
| 11 | + reason="Fatal Python error: Aborted on Linux CI when not using conda") |
| 12 | +def test_qfontmetrics_width(qtbot): |
| 13 | + """Test QFontMetrics width""" |
| 14 | + assert QtGui.QFontMetrics.width is not None |
| 15 | + font = QtGui.QFont("times", 24) |
| 16 | + font_metrics = QtGui.QFontMetrics(font) |
| 17 | + width = font_metrics.width("Test") |
| 18 | + assert width in range(40, 62) |
| 19 | + |
| 20 | + |
| 21 | +@pytest.mark.skipif(sys.platform.startswith('linux') and os.environ.get('USE_CONDA', 'No') == 'No', |
| 22 | + reason="Fatal Python error: Aborted on Linux CI when not using conda") |
| 23 | +def test_qdrag_functions(qtbot): |
8 | 24 | """Test functions mapping for QtGui.QDrag."""
|
9 |
| - assert QtGui.QDrag.exec_ |
| 25 | + assert QtGui.QDrag.exec_ is not None |
| 26 | + drag = QtGui.QDrag(None) |
| 27 | + drag.exec_() |
10 | 28 |
|
11 | 29 |
|
12 | 30 | def test_qguiapplication_functions():
|
13 | 31 | """Test functions mapping for QtGui.QGuiApplication."""
|
14 |
| - assert QtGui.QGuiApplication.exec_ |
| 32 | + assert QtGui.QGuiApplication.exec_ is not None |
15 | 33 |
|
16 | 34 |
|
| 35 | +@pytest.mark.skipif(sys.platform.startswith('linux') and os.environ.get('USE_CONDA', 'No') == 'No', |
| 36 | + reason="Segmentation fault/Aborted on Linux CI when not using conda") |
17 | 37 | def test_qtextdocument_functions():
|
18 | 38 | """Test functions mapping for QtGui.QTextDocument."""
|
19 |
| - assert QtGui.QTextDocument.print_ |
| 39 | + assert QtGui.QTextDocument.print_ is not None |
| 40 | + text_document = QtGui.QTextDocument("Test") |
| 41 | + print_device = QtGui.QPdfWriter('test.pdf') |
| 42 | + text_document.print_(print_device) |
| 43 | + assert os.path.exists('test.pdf') |
| 44 | + os.remove('test.pdf') |
20 | 45 |
|
21 | 46 |
|
22 | 47 | @pytest.mark.skipif(PYQT5 and PYQT_VERSION.startswith('5.9'),
|
|
0 commit comments