From 48c9f556ef17d67b820ac36944f5ee234dd624c6 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 4 Apr 2020 12:33:15 +0200 Subject: [PATCH] Fix tests: use explicit syspathinsert where tests might hang (#7008) Use `testdir.syspathinsert()` with multiprocessing tests: - test_chained_exceptions_no_reprcrash - test_exception_handling_no_traceback This only works currently because `_importtestmodule` changes `sys.path` as a side-effect. It appears to be only required on Windows though - likely due to the multiprocessing method used there. --- testing/test_assertion.py | 1 + testing/test_reports.py | 1 + 2 files changed, 2 insertions(+) diff --git a/testing/test_assertion.py b/testing/test_assertion.py index 3ce0f93e6..e6e42b6dd 100644 --- a/testing/test_assertion.py +++ b/testing/test_assertion.py @@ -1264,6 +1264,7 @@ def test_exception_handling_no_traceback(testdir): multitask_job() """ ) + testdir.syspathinsert() result = testdir.runpytest(p1, "--tb=long") result.stdout.fnmatch_lines( [ diff --git a/testing/test_reports.py b/testing/test_reports.py index 8c509ec47..13f593215 100644 --- a/testing/test_reports.py +++ b/testing/test_reports.py @@ -362,6 +362,7 @@ class TestReportSerialization: """ ) + testdir.syspathinsert() reprec = testdir.inline_run() reports = reprec.getreports("pytest_runtest_logreport")