diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-05-27 17:39:22 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2012-05-27 17:39:22 (GMT) |
commit | b3b49cd1d2498b65ff0ace4c7c9acf3e4475a798 (patch) | |
tree | f95a922d5297ce3b581859808ce48e68451c5917 /Lib/test | |
parent | 36432ea783a26cfbaecb05babb69ee31c00fe150 (diff) | |
download | cpython-b3b49cd1d2498b65ff0ace4c7c9acf3e4475a798.zip cpython-b3b49cd1d2498b65ff0ace4c7c9acf3e4475a798.tar.gz cpython-b3b49cd1d2498b65ff0ace4c7c9acf3e4475a798.tar.bz2 |
Refined venv tests.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_venv.py | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/Lib/test/test_venv.py b/Lib/test/test_venv.py index 2f2558f..108f2cc 100644 --- a/Lib/test/test_venv.py +++ b/Lib/test/test_venv.py @@ -52,19 +52,19 @@ class BaseTest(unittest.TestCase): class BasicTest(BaseTest): """Test venv module functionality.""" + def isdir(self, *args): + fn = self.get_env_file(*args) + self.assertTrue(os.path.isdir(fn)) + def test_defaults(self): """ Test the create function with default arguments. """ - def isdir(*args): - fn = self.get_env_file(*args) - self.assertTrue(os.path.isdir(fn)) - shutil.rmtree(self.env_dir) self.run_with_capture(venv.create, self.env_dir) - isdir(self.bindir) - isdir(self.include) - isdir(*self.lib) + self.isdir(self.bindir) + self.isdir(self.include) + self.isdir(*self.lib) data = self.get_text_file_contents('pyvenv.cfg') if sys.platform == 'darwin' and ('__PYTHONV_LAUNCHER__' in os.environ): @@ -77,8 +77,9 @@ class BasicTest(BaseTest): self.assertTrue(data.startswith('#!%s%s' % (self.env_dir, os.sep))) fn = self.get_env_file(self.bindir, self.exe) if not os.path.exists(fn): # diagnostics for Windows buildbot failures - print('Contents of %r:' % self.bindir) - print(' %r' % os.listdir(self.bindir)) + bd = self.get_env_file(self.bindir) + print('Contents of %r:' % bd) + print(' %r' % os.listdir(bd)) self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn) def test_overwrite_existing(self): @@ -89,6 +90,22 @@ class BasicTest(BaseTest): builder = venv.EnvBuilder(clear=True) builder.create(self.env_dir) + def test_upgrade(self): + """ + Test upgrading an existing environment directory. + """ + builder = venv.EnvBuilder(upgrade=True) + self.run_with_capture(builder.create, self.env_dir) + self.isdir(self.bindir) + self.isdir(self.include) + self.isdir(*self.lib) + fn = self.get_env_file(self.bindir, self.exe) + if not os.path.exists(fn): # diagnostics for Windows buildbot failures + bd = self.get_env_file(self.bindir) + print('Contents of %r:' % bd) + print(' %r' % os.listdir(bd)) + self.assertTrue(os.path.exists(fn), 'File %r should exist.' % fn) + def test_isolation(self): """ Test isolation from system site-packages |