Use support.change_cwd() in tests.

This commit is contained in:
Serhiy Storchaka 2015-09-06 14:14:49 +03:00
commit 5fbadb63ef
9 changed files with 34 additions and 104 deletions

View file

@ -63,11 +63,9 @@ class PyCompileTests(unittest.TestCase):
self.assertTrue(os.path.exists(self.cache_path))
def test_cwd(self):
cwd = os.getcwd()
os.chdir(self.directory)
py_compile.compile(os.path.basename(self.source_path),
os.path.basename(self.pyc_path))
os.chdir(cwd)
with support.change_cwd(self.directory):
py_compile.compile(os.path.basename(self.source_path),
os.path.basename(self.pyc_path))
self.assertTrue(os.path.exists(self.pyc_path))
self.assertFalse(os.path.exists(self.cache_path))