@@ -52,19 +52,19 @@ def get_text_file_contents(self, *args):
52
52
class BasicTest (BaseTest ):
53
53
"""Test venv module functionality."""
54
54
55
+ def isdir (self , * args ):
56
+ fn = self .get_env_file (* args )
57
+ self .assertTrue (os .path .isdir (fn ))
58
+
55
59
def test_defaults (self ):
56
60
"""
57
61
Test the create function with default arguments.
58
62
"""
59
- def isdir (* args ):
60
- fn = self .get_env_file (* args )
61
- self .assertTrue (os .path .isdir (fn ))
62
-
63
63
shutil .rmtree (self .env_dir )
64
64
self .run_with_capture (venv .create , self .env_dir )
65
- isdir (self .bindir )
66
- isdir (self .include )
67
- isdir (* self .lib )
65
+ self . isdir (self .bindir )
66
+ self . isdir (self .include )
67
+ self . isdir (* self .lib )
68
68
data = self .get_text_file_contents ('pyvenv.cfg' )
69
69
if sys .platform == 'darwin' and ('__PYTHONV_LAUNCHER__'
70
70
in os .environ ):
@@ -77,8 +77,9 @@ def isdir(*args):
77
77
self .assertTrue (data .startswith ('#!%s%s' % (self .env_dir , os .sep )))
78
78
fn = self .get_env_file (self .bindir , self .exe )
79
79
if not os .path .exists (fn ): # diagnostics for Windows buildbot failures
80
- print ('Contents of %r:' % self .bindir )
81
- print (' %r' % os .listdir (self .bindir ))
80
+ bd = self .get_env_file (self .bindir )
81
+ print ('Contents of %r:' % bd )
82
+ print (' %r' % os .listdir (bd ))
82
83
self .assertTrue (os .path .exists (fn ), 'File %r should exist.' % fn )
83
84
84
85
def test_overwrite_existing (self ):
@@ -89,6 +90,22 @@ def test_overwrite_existing(self):
89
90
builder = venv .EnvBuilder (clear = True )
90
91
builder .create (self .env_dir )
91
92
93
+ def test_upgrade (self ):
94
+ """
95
+ Test upgrading an existing environment directory.
96
+ """
97
+ builder = venv .EnvBuilder (upgrade = True )
98
+ self .run_with_capture (builder .create , self .env_dir )
99
+ self .isdir (self .bindir )
100
+ self .isdir (self .include )
101
+ self .isdir (* self .lib )
102
+ fn = self .get_env_file (self .bindir , self .exe )
103
+ if not os .path .exists (fn ): # diagnostics for Windows buildbot failures
104
+ bd = self .get_env_file (self .bindir )
105
+ print ('Contents of %r:' % bd )
106
+ print (' %r' % os .listdir (bd ))
107
+ self .assertTrue (os .path .exists (fn ), 'File %r should exist.' % fn )
108
+
92
109
def test_isolation (self ):
93
110
"""
94
111
Test isolation from system site-packages
0 commit comments