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 ,
@@ -126,7 +130,7 @@ def test_prompt(self):
126130 self .assertEqual (context .prompt , '(My prompt) ' )
127131 self .assertIn ("prompt = 'My prompt'\n " , data )
128132
129- @skipInVenv
133+ @requireVenvCreate
130134 def test_prefixes (self ):
131135 """
132136 Test that the prefix values are as expected.
@@ -262,7 +266,7 @@ def test_symlinking(self):
262266 # run the test, the pyvenv.cfg in the venv created in the test will
263267 # point to the venv being used to run the test, and we lose the link
264268 # to the source build - so Python can't initialise properly.
265- @skipInVenv
269+ @requireVenvCreate
266270 def test_executable (self ):
267271 """
268272 Test that the sys.executable value is as expected.
@@ -306,6 +310,7 @@ def test_unicode_in_batch_file(self):
306310 )
307311 self .assertEqual (out .strip (), '0' )
308312
313+ @requireVenvCreate
309314 def test_multiprocessing (self ):
310315 """
311316 Test that the multiprocessing is able to spawn.
@@ -319,7 +324,7 @@ def test_multiprocessing(self):
319324 'print(Pool(1).apply_async("Python".lower).get(3))' ])
320325 self .assertEqual (out .strip (), "python" .encode ())
321326
322- @skipInVenv
327+ @requireVenvCreate
323328class EnsurePipTest (BaseTest ):
324329 """Test venv module installation of pip."""
325330 def assert_pip_not_installed (self ):
0 commit comments