Skip to content

Commit 9f4e3ca

Browse files
committed
tests/wm: reduce number of app restarts
1 parent 1a7a0b3 commit 9f4e3ca

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

test/test_wm.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -691,12 +691,26 @@ def test_resize_maximize_unmaximize(
691691
@classmethod
692692
def get_parametrization(cls, name):
693693
p = load_params(PARAMS_DIR / f'{name}.gen').filter('class', cls)
694+
694695
# Reduce monitor config changes - more like in real use, and faster
695696
# Note: last order_by() has highest priority
696697
p = p.order_by('monitor1_scale').order_by('monitor0_scale')
697698
p = p.order_by('primary_monitor')
698-
p = p.order_by('layout_mode') # Change requires restarting the app
699-
p = p.order_by('gdk_backend') # Change requires restarting the app
699+
700+
# Hack: reduce app restarts by altering sort order
701+
# So if the first test method ends with layout_mode=PHYSICAL,
702+
# the second one will start with layout_mode=PHYSICAL
703+
if '_testmethods' not in cls.__dict__:
704+
cls._testmethods = []
705+
706+
if name not in cls._testmethods:
707+
cls._testmethods.append(name)
708+
709+
reverse = cls._testmethods.index(name) % 2 == 1
710+
711+
p = p.order_by('layout_mode', reverse) # Change requires restarting the app
712+
p = p.order_by('gdk_backend', reverse) # Change requires restarting the app
713+
700714
return p
701715

702716
def pytest_generate_tests(self, metafunc):

0 commit comments

Comments
 (0)