https://github.com/python/cpython/commit/a4722449caccc42ad644611d02fbdb5005f601eb
commit: a4722449caccc42ad644611d02fbdb5005f601eb
branch: main
author: Filipe Laíns 🇵🇸 <[email protected]>
committer: FFY00 <[email protected]>
date: 2025-01-30T03:32:24Z
summary:
tests: add test.support.venv.VirtualEnvironmentMixin (#129461)
files:
M Lib/test/support/venv.py
M Lib/test/test_sysconfig.py
diff --git a/Lib/test/support/venv.py b/Lib/test/support/venv.py
index 78e6a51ec1815e..7bfb9e4f3c479f 100644
--- a/Lib/test/support/venv.py
+++ b/Lib/test/support/venv.py
@@ -6,6 +6,7 @@
import sys
import sysconfig
import tempfile
+import unittest
import venv
@@ -68,3 +69,14 @@ def run(self, *args, **subprocess_args):
raise
else:
return result
+
+
+class VirtualEnvironmentMixin:
+ def venv(self, name=None, **venv_create_args):
+ venv_name = self.id()
+ if name:
+ venv_name += f'-{name}'
+ return VirtualEnvironment.from_tmpdir(
+ prefix=f'{venv_name}-venv-',
+ **venv_create_args,
+ )
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index 3950d8888d4c8c..3738914cf17de8 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -20,7 +20,7 @@
from test.support.import_helper import import_module
from test.support.os_helper import (TESTFN, unlink, skip_unless_symlink,
change_cwd)
-from test.support.venv import VirtualEnvironment
+from test.support.venv import VirtualEnvironmentMixin
import sysconfig
from sysconfig import (get_paths, get_platform, get_config_vars,
@@ -37,7 +37,7 @@
HAS_USER_BASE = sysconfig._HAS_USER_BASE
-class TestSysConfig(unittest.TestCase):
+class TestSysConfig(unittest.TestCase, VirtualEnvironmentMixin):
def setUp(self):
super(TestSysConfig, self).setUp()
@@ -111,13 +111,6 @@ def _cleanup_testfn(self):
elif os.path.isdir(path):
shutil.rmtree(path)
- def venv(self, **venv_create_args):
- return VirtualEnvironment.from_tmpdir(
- prefix=f'{self.id()}-venv-',
- **venv_create_args,
- )
-
-
def test_get_path_names(self):
self.assertEqual(get_path_names(), sysconfig._SCHEME_KEYS)
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]