import sys
import sysconfig
import tempfile
+import unittest
import venv
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,
+ )
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,
HAS_USER_BASE = sysconfig._HAS_USER_BASE
-class TestSysConfig(unittest.TestCase):
+class TestSysConfig(unittest.TestCase, VirtualEnvironmentMixin):
def setUp(self):
super(TestSysConfig, self).setUp()
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)