8000 tests: add test.support.venv.VirtualEnvironmentMixin by FFY00 · Pull Request #129461 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

tests: add test.support.venv.VirtualEnvironmentMixin #129461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Lib/test/support/venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import sys
import sysconfig
import tempfile
import unittest
import venv


Expand Down Expand Up @@ -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,
)
11 changes: 2 additions & 9 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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)

Expand Down
Loading
0