summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@nexedi.com>2020-07-15 16:43:37 +0300
committerGitHub <noreply@github.com>2020-07-15 14:43:37 +0100
commitcd17f3030c1ca93e835d663b0bba5526bc359bf9 (patch)
tree562d200c8536cc65c03571e1cc147b38d315f8d2 /tests/unit
parent16f80ac89d614551240650705fc3630f24974506 (diff)
downloadvirtualenv-cd17f3030c1ca93e835d663b0bba5526bc359bf9.tar.gz
Don't preimport threading early (#1897)
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/create/test_creator.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py
index 5a24df6..10090c7 100644
--- a/tests/unit/create/test_creator.py
+++ b/tests/unit/create/test_creator.py
@@ -557,3 +557,19 @@ def test_zip_importer_can_import_setuptools(tmp_path):
env = os.environ.copy()
env[str("PYTHONPATH")] = str(zip_path)
subprocess.check_call([str(result.creator.exe), "-c", "from setuptools.dist import Distribution"], env=env)
+
+
+# verify that python in created virtualenv does not preimport threading.
+# https://github.com/pypa/virtualenv/issues/1895
+#
+# coverage is disabled, because when coverage is active, it imports threading in default mode.
+@pytest.mark.xfail(
+ IS_PYPY and PY3 and sys.platform.startswith("darwin"), reason="https://foss.heptapod.net/pypy/pypy/-/issues/3269",
+)
+def test_no_preimport_threading(tmp_path, no_coverage):
+ session = cli_run([ensure_text(str(tmp_path))])
+ out = subprocess.check_output(
+ [str(session.creator.exe), "-c", r"import sys; print('\n'.join(sorted(sys.modules)))"], universal_newlines=True,
+ )
+ imported = set(out.splitlines())
+ assert "threading" not in imported