diff options
author | Brett Cannon <brett@python.org> | 2013-06-12 19:57:01 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2013-06-12 19:57:01 (GMT) |
commit | 638ce0779b4dceea39c2f77346aeab9824e48548 (patch) | |
tree | dfe7858f242bb9a6027516abc4eeb05bd605027b /Lib/test/test_zipimport.py | |
parent | f15ffe0ee5af54cb1669be8195866c6edbd5fe72 (diff) | |
download | cpython-638ce0779b4dceea39c2f77346aeab9824e48548.zip cpython-638ce0779b4dceea39c2f77346aeab9824e48548.tar.gz cpython-638ce0779b4dceea39c2f77346aeab9824e48548.tar.bz2 |
Move code from test_importhooks into test_zipimport.
Diffstat (limited to 'Lib/test/test_zipimport.py')
-rw-r--r-- | Lib/test/test_zipimport.py | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index a60d3e0..2e2297b 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -7,7 +7,6 @@ import time import unittest from test import support -from test.test_importhooks import ImportHooksBaseTestCase, test_src, test_co from zipfile import ZipFile, ZipInfo, ZIP_STORED, ZIP_DEFLATED @@ -17,6 +16,14 @@ import doctest import inspect import io from traceback import extract_tb, extract_stack, print_tb + +test_src = """\ +def get_name(): + return __name__ +def get_file(): + return __file__ +""" +test_co = compile(test_src, "<???>", "exec") raise_src = 'def do_raise(): raise TypeError\n' def make_pyc(co, mtime, size): @@ -46,6 +53,23 @@ pyc_file = imp.cache_from_source(TESTMOD + '.py') pyc_ext = ('.pyc' if __debug__ else '.pyo') +class ImportHooksBaseTestCase(unittest.TestCase): + + def setUp(self): + self.path = sys.path[:] + self.meta_path = sys.meta_path[:] + self.path_hooks = sys.path_hooks[:] + sys.path_importer_cache.clear() + self.modules_before = support.modules_setup() + + def tearDown(self): + sys.path[:] = self.path + sys.meta_path[:] = self.meta_path + sys.path_hooks[:] = self.path_hooks + sys.path_importer_cache.clear() + support.modules_cleanup(*self.modules_before) + + class UncompressedZipImportTestCase(ImportHooksBaseTestCase): compression = ZIP_STORED |