Mercurial > cpython-lru_cache-weakref
comparison Lib/test/test_httpservers.py @ 59914:f0014554166f legacy-trunk
#7668: Fix test_httpservers failure when sys.executable contains non-ASCII bytes.
| author | Florent Xicluna <florent.xicluna@gmail.com> |
|---|---|
| date | Mon, 22 Mar 2010 17:18:18 +0000 |
| parents | 07c7664f21a1 |
| children | 5ac0aae28f4c |
comparison
equal
deleted
inserted
replaced
| 59913:767b0831659e | 59914:f0014554166f |
|---|---|
| 295 BaseTestCase.setUp(self) | 295 BaseTestCase.setUp(self) |
| 296 self.parent_dir = tempfile.mkdtemp() | 296 self.parent_dir = tempfile.mkdtemp() |
| 297 self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') | 297 self.cgi_dir = os.path.join(self.parent_dir, 'cgi-bin') |
| 298 os.mkdir(self.cgi_dir) | 298 os.mkdir(self.cgi_dir) |
| 299 | 299 |
| 300 # The shebang line should be pure ASCII: use symlink if possible. | |
| 301 # See issue #7668. | |
| 302 if hasattr(os, 'symlink'): | |
| 303 self.pythonexe = os.path.join(self.parent_dir, 'python') | |
| 304 os.symlink(sys.executable, self.pythonexe) | |
| 305 else: | |
| 306 self.pythonexe = sys.executable | |
| 307 | |
| 300 self.file1_path = os.path.join(self.cgi_dir, 'file1.py') | 308 self.file1_path = os.path.join(self.cgi_dir, 'file1.py') |
| 301 with open(self.file1_path, 'w') as file1: | 309 with open(self.file1_path, 'w') as file1: |
| 302 file1.write(cgi_file1 % sys.executable) | 310 file1.write(cgi_file1 % self.pythonexe) |
| 303 os.chmod(self.file1_path, 0777) | 311 os.chmod(self.file1_path, 0777) |
| 304 | 312 |
| 305 self.file2_path = os.path.join(self.cgi_dir, 'file2.py') | 313 self.file2_path = os.path.join(self.cgi_dir, 'file2.py') |
| 306 with open(self.file2_path, 'w') as file2: | 314 with open(self.file2_path, 'w') as file2: |
| 307 file2.write(cgi_file2 % sys.executable) | 315 file2.write(cgi_file2 % self.pythonexe) |
| 308 os.chmod(self.file2_path, 0777) | 316 os.chmod(self.file2_path, 0777) |
| 309 | 317 |
| 310 self.cwd = os.getcwd() | 318 self.cwd = os.getcwd() |
| 311 os.chdir(self.parent_dir) | 319 os.chdir(self.parent_dir) |
| 312 | 320 |
| 313 def tearDown(self): | 321 def tearDown(self): |
| 314 try: | 322 try: |
| 315 os.chdir(self.cwd) | 323 os.chdir(self.cwd) |
| 324 if self.pythonexe != sys.executable: | |
| 325 os.remove(self.pythonexe) | |
| 316 os.remove(self.file1_path) | 326 os.remove(self.file1_path) |
| 317 os.remove(self.file2_path) | 327 os.remove(self.file2_path) |
| 318 os.rmdir(self.cgi_dir) | 328 os.rmdir(self.cgi_dir) |
| 319 os.rmdir(self.parent_dir) | 329 os.rmdir(self.parent_dir) |
| 320 finally: | 330 finally: |
