diff --git a/changelog/4913.trivial.rst b/changelog/4913.trivial.rst new file mode 100644 index 000000000..7846775cc --- /dev/null +++ b/changelog/4913.trivial.rst @@ -0,0 +1 @@ +Fix pytest tests invocation with custom ``PYTHONPATH``. diff --git a/testing/test_collection.py b/testing/test_collection.py index 97c46d8c2..37f7ad89c 100644 --- a/testing/test_collection.py +++ b/testing/test_collection.py @@ -2,6 +2,7 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function +import os import pprint import sys import textwrap @@ -1108,7 +1109,7 @@ def test_collect_pyargs_with_testpaths(testdir, monkeypatch): """ ) ) - monkeypatch.setenv("PYTHONPATH", str(testdir.tmpdir)) + monkeypatch.setenv("PYTHONPATH", str(testdir.tmpdir), prepend=os.pathsep) with root.as_cwd(): result = testdir.runpytest_subprocess() result.stdout.fnmatch_lines(["*1 passed in*"])