| LEFT | RIGHT |
| 1 """ | 1 """ |
| 2 Test harness for the venv module. | 2 Test harness for the venv module. |
| 3 | 3 |
| 4 Copyright (C) 2011-2012 Vinay Sajip. | 4 Copyright (C) 2011-2012 Vinay Sajip. |
| 5 Licensed to the PSF under a contributor agreement. | 5 Licensed to the PSF under a contributor agreement. |
| 6 """ | 6 """ |
| 7 | 7 |
| 8 import os | 8 import os |
| 9 import os.path | 9 import os.path |
| 10 import shutil | 10 import shutil |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 for usl in (False, True): | 153 for usl in (False, True): |
| 154 builder = venv.EnvBuilder(clear=True, symlinks=usl) | 154 builder = venv.EnvBuilder(clear=True, symlinks=usl) |
| 155 builder.create(self.env_dir) | 155 builder.create(self.env_dir) |
| 156 fn = self.get_env_file(self.bindir, self.exe) | 156 fn = self.get_env_file(self.bindir, self.exe) |
| 157 # Don't test when False, because e.g. 'python' is always | 157 # Don't test when False, because e.g. 'python' is always |
| 158 # symlinked to 'python3.3' in the env, even when symlinking in | 158 # symlinked to 'python3.3' in the env, even when symlinking in |
| 159 # general isn't wanted. | 159 # general isn't wanted. |
| 160 if usl: | 160 if usl: |
| 161 self.assertTrue(os.path.islink(fn)) | 161 self.assertTrue(os.path.islink(fn)) |
| 162 | 162 |
| 163 def test_executable(self): |
| 164 """ |
| 165 Test that the sys.executable value is as expected. |
| 166 """ |
| 167 shutil.rmtree(self.env_dir) |
| 168 self.run_with_capture(venv.create, self.env_dir) |
| 169 envpy = os.path.join(os.path.realpath(self.env_dir), self.bindir, self.e
xe) |
| 170 cmd = [envpy, '-c', 'import sys; print(sys.executable)'] |
| 171 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
| 172 stderr=subprocess.PIPE) |
| 173 out, err = p.communicate() |
| 174 self.assertEqual(out[:-1], envpy.encode()) |
| 175 |
| 176 @unittest.skipUnless(can_symlink(), 'Needs symlinks') |
| 177 def test_executable_symlinks(self): |
| 178 """ |
| 179 Test that the sys.executable value is as expected. |
| 180 """ |
| 181 shutil.rmtree(self.env_dir) |
| 182 builder = venv.EnvBuilder(clear=True, symlinks=True) |
| 183 builder.create(self.env_dir) |
| 184 envpy = os.path.join(os.path.realpath(self.env_dir), self.bindir, self.e
xe) |
| 185 cmd = [envpy, '-c', 'import sys; print(sys.executable)'] |
| 186 p = subprocess.Popen(cmd, stdout=subprocess.PIPE, |
| 187 stderr=subprocess.PIPE) |
| 188 out, err = p.communicate() |
| 189 self.assertEqual(out[:-1], envpy.encode()) |
| 190 |
| 163 def test_main(): | 191 def test_main(): |
| 164 run_unittest(BasicTest) | 192 run_unittest(BasicTest) |
| 165 | 193 |
| 166 if __name__ == "__main__": | 194 if __name__ == "__main__": |
| 167 test_main() | 195 test_main() |
| LEFT | RIGHT |