Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e101040

Browse files
committed
TST: Force qt?_module fixture to be run first.
If it's not run first, then the `mpl_test_settings` fixture will attempt to switch backends before the skip is triggered.
1 parent a68583e commit e101040

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

lib/matplotlib/tests/test_backend_qt4.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@
88
import pytest
99

1010

11-
@pytest.fixture(autouse=True)
11+
def pytest_generate_tests(metafunc):
12+
"""
13+
Insert qt4_module fixture as *first* fixture.
14+
15+
It is very important that it is first, because it skips tests when Qt4 is
16+
not available. Making it an autouse fixture, or using it as a parameter
17+
would not leave it first. If this fixture is not first, then the
18+
`mpl_test_settings` fixture will try to switch backends before the skip can
19+
be triggered.
20+
"""
21+
metafunc.fixturenames.insert(0, 'qt4_module')
22+
23+
24+
@pytest.fixture
1225
def qt4_module():
1326
try:
1427
import PyQt4

lib/matplotlib/tests/test_backend_qt5.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@
88
import pytest
99

1010

11-
@pytest.fixture(autouse=True)
11+
def pytest_generate_tests(metafunc):
12+
"""
13+
Insert qt5_module fixture as *first* fixture.
14+
15+
It is very important that it is first, because it skips tests when Qt5 is
16+
not available. Making it an autouse fixture, or using it as a parameter
17+
would not leave it first. If this fixture is not first, then the
18+
`mpl_test_settings` fixture will try to switch backends before the skip can
19+
be triggered.
20+
"""
21+
metafunc.fixturenames.insert(0, 'qt5_module')
22+
23+
24+
@pytest.fixture
1225
def qt5_module():
1326
try:
1427
import PyQt5

0 commit comments

Comments
 (0)