Skip to content

Commit 9ce30c1

Browse files
committed
tests: Fix test_header patching leaking into other tests
Since we run pytester in-process, the patching of qt_api.get_versions will leak into the rest of the testsuite (even if done in a temporary conftest.py, the qt_api module is the same!). This causes Qt API version checks in the testsuite to be broken.
1 parent 0b88127 commit 9ce30c1

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

tests/test_basics.py

+6-13
Original file line numberDiff line numberDiff line change
@@ -309,20 +309,13 @@ def test_events(events_queue, fix, i):
309309
res.stdout.fnmatch_lines(["*3 passed in*"])
310310

311311

312-
def test_header(testdir):
313-
testdir.makeconftest(
314-
"""
315-
from pytestqt import qt_compat
316-
from pytestqt.qt_compat import qt_api
317-
318-
def mock_get_versions():
319-
return qt_compat.VersionTuple('PyQtAPI', '1.0', '2.5', '3.5')
320-
321-
assert hasattr(qt_api, 'get_versions')
322-
qt_api.get_versions = mock_get_versions
323-
"""
312+
def test_header(testdir, monkeypatch):
313+
monkeypatch.setattr(
314+
qt_api,
315+
"get_versions",
316+
lambda: qt_compat.VersionTuple("PyQtAPI", "1.0", "2.5", "3.5"),
324317
)
325-
res = testdir.runpytest()
318+
res = testdir.runpytest_inprocess()
326319
res.stdout.fnmatch_lines(
327320
["*test session starts*", "PyQtAPI 1.0 -- Qt runtime 2.5 -- Qt compiled 3.5"]
328321
)

0 commit comments

Comments
 (0)