2424except ImportError :
2525 ctypes = None
2626
27- skipInVenv = unittest .skipIf (sys .prefix != sys .base_prefix ,
28- 'Test not appropriate in a venv' )
27+ # Platforms that set sys._base_executable can create venvs from within
28+ # another venv, so no need to skip tests that require venv.create().
29+ requireVenvCreate = unittest .skipUnless (
30+ hasattr (sys , '_base_executable' )
31+ or sys .prefix == sys .base_prefix ,
32+ 'cannot run venv.create from within a venv on this platform' )
2933
3034def check_output (cmd , encoding = None ):
3135 p = subprocess .Popen (cmd ,
@@ -118,7 +122,7 @@ def test_prompt(self):
118122 context = builder .ensure_directories (self .env_dir )
119123 self .assertEqual (context .prompt , '(My prompt) ' )
120124
121- @skipInVenv
125+ @requireVenvCreate
122126 def test_prefixes (self ):
123127 """
124128 Test that the prefix values are as expected.
@@ -254,7 +258,7 @@ def test_symlinking(self):
254258 # run the test, the pyvenv.cfg in the venv created in the test will
255259 # point to the venv being used to run the test, and we lose the link
256260 # to the source build - so Python can't initialise properly.
257- @skipInVenv
261+ @requireVenvCreate
258262 def test_executable (self ):
259263 """
260264 Test that the sys.executable value is as expected.
@@ -298,6 +302,7 @@ def test_unicode_in_batch_file(self):
298302 )
299303 self .assertEqual (out .strip (), '0' )
300304
305+ @requireVenvCreate
301306 def test_multiprocessing (self ):
302307 """
303308 Test that the multiprocessing is able to spawn.
@@ -311,7 +316,7 @@ def test_multiprocessing(self):
311316 'print(Pool(1).apply_async("Python".lower).get(3))' ])
312317 self .assertEqual (out .strip (), "python" .encode ())
313318
314- @skipInVenv
319+ @requireVenvCreate
315320class EnsurePipTest (BaseTest ):
316321 """Test venv module installation of pip."""
317322 def assert_pip_not_installed (self ):
0 commit comments