diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-07-03 15:56:40 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-07-03 15:56:40 (GMT) |
commit | 3874e547b4779978952792bc19c438c28daca125 (patch) | |
tree | bc239321c153d027540689eb017a52fd6bea60cd /Lib/test/test_venv.py | |
parent | abd344cbab00851911c89a5202da1aa601ab47c7 (diff) | |
download | cpython-3874e547b4779978952792bc19c438c28daca125.zip cpython-3874e547b4779978952792bc19c438c28daca125.tar.gz cpython-3874e547b4779978952792bc19c438c28daca125.tar.bz2 |
Issue #15241: Added test for venv prefixes.
Diffstat (limited to 'Lib/test/test_venv.py')
-rw-r--r-- | Lib/test/test_venv.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 705fd39..3750c36 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -8,6 +8,7 @@ Licensed to the PSF under a contributor agreement. import os import os.path import shutil +import subprocess import sys import tempfile from test.support import (captured_stdout, captured_stderr, run_unittest, @@ -86,6 +87,30 @@ class BasicTest(BaseTest): print(' %r' % os.listdir(bd)) self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn) + def test_prefixes(self): + """ + Test that the prefix values are as expected. + """ + #check our prefixes + self.assertEqual(sys.base_prefix, sys.prefix) + self.assertEqual(sys.base_exec_prefix, sys.exec_prefix) + + # check a venv's prefixes + shutil.rmtree(self.env_dir) + self.run_with_capture(venv.create, self.env_dir) + envpy = os.path.join(self.env_dir, self.bindir, self.exe) + cmd = [envpy, '-c', None] + for prefix, expected in ( + ('prefix', self.env_dir), + ('prefix', self.env_dir), + ('base_prefix', sys.prefix), + ('base_exec_prefix', sys.exec_prefix)): + cmd[2] = 'import sys; print(sys.%s)' % prefix + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + out, err = p.communicate() + self.assertEqual(out[:-1], expected.encode()) + def test_overwrite_existing(self): """ Test control of overwriting an existing environment directory. |