summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernát Gábor <bgabor8@bloomberg.net>2020-07-06 22:59:19 +0100
committerGitHub <noreply@github.com>2020-07-06 22:59:19 +0100
commit23cf27f514b2bc8ee81a51244496256735a2b13c (patch)
tree39f246c4f195703eafb7b2cdd69048fd942369c2
parent255a6d5cc74e3b1e3ec66243726abdc3ba2ae3d4 (diff)
downloadvirtualenv-23cf27f514b2bc8ee81a51244496256735a2b13c.tar.gz
Fix test suite failing if run under system Python (#1888)
Signed-off-by: Bernat Gabor <bgabor8@bloomberg.net>
-rw-r--r--docs/changelog/1882.bufix.rst1
-rw-r--r--tests/conftest.py7
-rw-r--r--tests/unit/discovery/py_info/test_py_info.py2
3 files changed, 9 insertions, 1 deletions
diff --git a/docs/changelog/1882.bufix.rst b/docs/changelog/1882.bufix.rst
new file mode 100644
index 0000000..25669a3
--- /dev/null
+++ b/docs/changelog/1882.bufix.rst
@@ -0,0 +1 @@
+Fix test suite failing if run from system Python - by :user:`gaborbernat`.
diff --git a/tests/conftest.py b/tests/conftest.py
index 97e109e..e69e4d7 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -342,3 +342,10 @@ def cross_python(is_inside_ci, session_app_data):
@pytest.fixture(scope="session")
def for_py_version():
return "{}.{}".format(*sys.version_info[0:2])
+
+
+@pytest.fixture()
+def skip_if_test_in_system(session_app_data):
+ current = PythonInfo.current(session_app_data)
+ if current.system_executable is not None:
+ pytest.skip("test not valid if run under system")
diff --git a/tests/unit/discovery/py_info/test_py_info.py b/tests/unit/discovery/py_info/test_py_info.py
index 11f3dcc..6ed11c3 100644
--- a/tests/unit/discovery/py_info/test_py_info.py
+++ b/tests/unit/discovery/py_info/test_py_info.py
@@ -299,7 +299,7 @@ def test_py_info_setuptools():
PythonInfo()
-def test_py_info_to_system_raises(session_app_data, mocker, caplog):
+def test_py_info_to_system_raises(session_app_data, mocker, caplog, skip_if_test_in_system):
caplog.set_level(logging.DEBUG)
mocker.patch.object(PythonInfo, "_find_possible_folders", return_value=[])
result = PythonInfo.from_exe(sys.executable, app_data=session_app_data, raise_on_error=False)