diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-06 11:16:18 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-09-06 11:16:18 (GMT) |
commit | 7c7b4b5d8664a240a8472e8275cf0e8ae2f3b19e (patch) | |
tree | 1f840b6ad9a0564b7fdead3c861253f1f79f0beb /Lib/test/test_py_compile.py | |
parent | 23ae488f23c7955a1b3448590d91b758e552764f (diff) | |
download | cpython-7c7b4b5d8664a240a8472e8275cf0e8ae2f3b19e.zip cpython-7c7b4b5d8664a240a8472e8275cf0e8ae2f3b19e.tar.gz cpython-7c7b4b5d8664a240a8472e8275cf0e8ae2f3b19e.tar.bz2 |
Backport support.change_cwd() and use it in tests.
Diffstat (limited to 'Lib/test/test_py_compile.py')
-rw-r--r-- | Lib/test/test_py_compile.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/Lib/test/test_py_compile.py b/Lib/test/test_py_compile.py index b919da2..5ec523a 100644 --- a/Lib/test/test_py_compile.py +++ b/Lib/test/test_py_compile.py @@ -5,7 +5,7 @@ import shutil import tempfile import unittest -from test import test_support +from test import test_support as support class PyCompileTests(unittest.TestCase): @@ -35,11 +35,9 @@ class PyCompileTests(unittest.TestCase): self.assertTrue(os.path.exists(self.pyc_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)) def test_relative_path(self): @@ -48,7 +46,7 @@ class PyCompileTests(unittest.TestCase): self.assertTrue(os.path.exists(self.pyc_path)) def test_main(): - test_support.run_unittest(PyCompileTests) + support.run_unittest(PyCompileTests) if __name__ == "__main__": test_main() |