diff options
Diffstat (limited to 'Lib/test')
| -rw-r--r-- | Lib/test/test_eof.py | 5 | ||||
| -rw-r--r-- | Lib/test/test_zipimport.py | 32 |
2 files changed, 35 insertions, 2 deletions
diff --git a/Lib/test/test_eof.py b/Lib/test/test_eof.py index 4284d11d08..91fd845551 100644 --- a/Lib/test/test_eof.py +++ b/Lib/test/test_eof.py @@ -6,7 +6,7 @@ from test import test_support class EOFTestCase(unittest.TestCase): def test_EOFC(self): - expect = "EOL while scanning single-quoted string (<string>, line 1)" + expect = "EOL while scanning string literal (<string>, line 1)" try: eval("""'this is a test\ """) @@ -16,7 +16,8 @@ class EOFTestCase(unittest.TestCase): raise test_support.TestFailed def test_EOFS(self): - expect = "EOF while scanning triple-quoted string (<string>, line 1)" + expect = ("EOF while scanning triple-quoted string literal " + "(<string>, line 1)") try: eval("""'''this is a test""") except SyntaxError as msg: diff --git a/Lib/test/test_zipimport.py b/Lib/test/test_zipimport.py index d2758b4d68..c7da859e6e 100644 --- a/Lib/test/test_zipimport.py +++ b/Lib/test/test_zipimport.py @@ -209,6 +209,7 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): z.close() zi = zipimport.zipimporter(TEMP_ZIP) + self.assertEquals(zi.archive, TEMP_ZIP) self.assertEquals(zi.is_package(TESTPACK), True) zi.load_module(TESTPACK) @@ -229,6 +230,37 @@ class UncompressedZipImportTestCase(ImportHooksBaseTestCase): z.close() os.remove(TEMP_ZIP) + def testZipImporterMethodsInSubDirectory(self): + packdir = TESTPACK + os.sep + packdir2 = packdir + TESTPACK2 + os.sep + files = {packdir2 + "__init__" + pyc_ext: (NOW, test_pyc), + packdir2 + TESTMOD + pyc_ext: (NOW, test_pyc)} + + z = ZipFile(TEMP_ZIP, "w") + try: + for name, (mtime, data) in files.items(): + zinfo = ZipInfo(name, time.localtime(mtime)) + zinfo.compress_type = self.compression + z.writestr(zinfo, data) + z.close() + + zi = zipimport.zipimporter(TEMP_ZIP + os.sep + packdir) + self.assertEquals(zi.archive, TEMP_ZIP) + self.assertEquals(zi.prefix, packdir) + self.assertEquals(zi.is_package(TESTPACK2), True) + zi.load_module(TESTPACK2) + + self.assertEquals(zi.is_package(TESTPACK2 + os.sep + '__init__'), False) + self.assertEquals(zi.is_package(TESTPACK2 + os.sep + TESTMOD), False) + + mod_name = TESTPACK2 + os.sep + TESTMOD + mod = __import__(module_path_to_dotted_name(mod_name)) + self.assertEquals(zi.get_source(TESTPACK2), None) + self.assertEquals(zi.get_source(mod_name), None) + finally: + z.close() + os.remove(TEMP_ZIP) + def testGetData(self): z = ZipFile(TEMP_ZIP, "w") z.compression = self.compression |
