diff options
| author | Barry Warsaw <barry@python.org> | 2012-07-31 20:03:25 (GMT) |
|---|---|---|
| committer | Barry Warsaw <barry@python.org> | 2012-07-31 20:03:25 (GMT) |
| commit | 9a5af1288deb62d975c044a45711cc179b5a2ad1 (patch) | |
| tree | 767b3a8dc1a144e66cc1e476ddd50a0a8e5cfb92 /Lib/test/test_import.py | |
| parent | dadebab42c87e29342de67501a6b280e547fb633 (diff) | |
| parent | 233f6845b3f3498d800b429c4e8d84abcb5726b7 (diff) | |
| download | cpython-9a5af1288deb62d975c044a45711cc179b5a2ad1.zip cpython-9a5af1288deb62d975c044a45711cc179b5a2ad1.tar.gz cpython-9a5af1288deb62d975c044a45711cc179b5a2ad1.tar.bz2 | |
merge
Diffstat (limited to 'Lib/test/test_import.py')
| -rw-r--r-- | Lib/test/test_import.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index 3e61577..2e58199 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -785,11 +785,13 @@ class ImportTracebackTests(unittest.TestCase): sys.path[:] = self.old_path rmtree(TESTFN) - def create_module(self, mod, contents): - with open(os.path.join(TESTFN, mod + ".py"), "w") as f: + def create_module(self, mod, contents, ext=".py"): + fname = os.path.join(TESTFN, mod + ext) + with open(fname, "w") as f: f.write(contents) self.addCleanup(unload, mod) importlib.invalidate_caches() + return fname def assert_traceback(self, tb, files): deduped_files = [] @@ -857,16 +859,14 @@ class ImportTracebackTests(unittest.TestCase): def _setup_broken_package(self, parent, child): pkg_name = "_parent_foo" - def cleanup(): - rmtree(pkg_name) - unload(pkg_name) - os.mkdir(pkg_name) - self.addCleanup(cleanup) + self.addCleanup(unload, pkg_name) + pkg_path = os.path.join(TESTFN, pkg_name) + os.mkdir(pkg_path) # Touch the __init__.py - init_path = os.path.join(pkg_name, '__init__.py') + init_path = os.path.join(pkg_path, '__init__.py') with open(init_path, 'w') as f: f.write(parent) - bar_path = os.path.join(pkg_name, 'bar.py') + bar_path = os.path.join(pkg_path, 'bar.py') with open(bar_path, 'w') as f: f.write(child) importlib.invalidate_caches() |
