File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -33,10 +33,22 @@ def pytest_addoption(parser):
3333
3434def pytest_configure (config ):
3535 """Configure pytest based on command line options."""
36+ config .addinivalue_line (
37+ "markers" ,
38+ "requires_display: mark test as requiring a display "
39+ "(skipped in offscreen mode)" ,
40+ )
3641 if not config .getoption ("--show-windows" ):
3742 os .environ .setdefault ("QT_QPA_PLATFORM" , "offscreen" )
3843
3944
45+ def pytest_runtest_setup (item ):
46+ """Run setup before each test."""
47+ if "requires_display" in item .keywords :
48+ if os .environ .get ("QT_QPA_PLATFORM" ) == "offscreen" :
49+ pytest .skip ("Skipped in offscreen mode (requires display)" )
50+
51+
4052@pytest .fixture (scope = "session" , autouse = True )
4153def disable_gc_for_tests ():
4254 """Disable garbage collection for all tests in the session."""
Original file line number Diff line number Diff line change 11from __future__ import annotations
22
3- import os
43from typing import TYPE_CHECKING , Callable , TypeVar
54
65import numpy as np
@@ -269,7 +268,7 @@ def test_select_all_items():
269268 exec_dialog (win )
270269
271270
272- @pytest .mark .skipif ( os . name != "nt" , reason = "Only tested on Windows." )
271+ @pytest .mark .requires_display
273272def test_rotate_with_mouse ():
274273 """Test rotating an image item with the mouse."""
275274 with qt_app_context (exec_loop = False ):
@@ -320,7 +319,7 @@ def test_rectangular_selection():
320319 exec_dialog (win )
321320
322321
323- @pytest .mark .skipif ( os . name != "nt" , reason = "Only tested on Windows." )
322+ @pytest .mark .requires_display
324323@pytest .mark .parametrize (
325324 "mouse_path, rotation" ,
326325 [
You can’t perform that action at this time.
0 commit comments