|
1 | 1 | """Tests for the main program with Qt.""" |
2 | | -import sys |
3 | | - |
4 | 2 | import pytest |
5 | 3 |
|
6 | 4 | import qdarktheme |
| 5 | +from qdarktheme.qtpy.QtWidgets import QApplication |
7 | 6 |
|
8 | 7 |
|
9 | 8 | @pytest.mark.parametrize( |
@@ -34,25 +33,11 @@ def test_load_palette(theme, custom_colors) -> None: |
34 | 33 | qdarktheme.load_palette(theme, custom_colors) |
35 | 34 |
|
36 | 35 |
|
37 | | -def test_apply_stylesheet_to_qt_app() -> None: |
| 36 | +def test_apply_stylesheet_to_qt_app(qapp: QApplication) -> None: |
38 | 37 | """Verify that the function `load_stylesheet()` runs without error.""" |
39 | | - from qdarktheme.qtpy.QtCore import Qt |
40 | | - from qdarktheme.qtpy.QtWidgets import QApplication |
41 | | - |
42 | | - app = QApplication.instance() if QApplication.instance() else QApplication(sys.argv) |
43 | | - if hasattr(Qt.ApplicationAttribute, "AA_UseHighDpiPixmaps"): |
44 | | - app.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps) # type: ignore |
45 | | - |
46 | | - app.setStyleSheet(qdarktheme.load_stylesheet()) |
| 38 | + qapp.setStyleSheet(qdarktheme.load_stylesheet()) |
47 | 39 |
|
48 | 40 |
|
49 | | -def test_apply_palette_to_qt_app() -> None: |
| 41 | +def test_apply_palette_to_qt_app(qapp: QApplication) -> None: |
50 | 42 | """Verify that the function `load_palette()` runs without error.""" |
51 | | - from qdarktheme.qtpy.QtCore import Qt |
52 | | - from qdarktheme.qtpy.QtWidgets import QApplication |
53 | | - |
54 | | - app = QApplication.instance() if QApplication.instance() else QApplication(sys.argv) |
55 | | - if hasattr(Qt.ApplicationAttribute, "AA_UseHighDpiPixmaps"): |
56 | | - app.setAttribute(Qt.ApplicationAttribute.AA_UseHighDpiPixmaps) # type: ignore |
57 | | - |
58 | | - app.setPalette(qdarktheme.load_palette()) |
| 43 | + qapp.setPalette(qdarktheme.load_palette()) |
0 commit comments