diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2007-11-16 00:56:23 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2007-11-16 00:56:23 (GMT) |
commit | dd9e3b8736fae1f730d027d5383a2b17c661ce82 (patch) | |
tree | 88aed29f2d777bc5dd81622b17088416a80c8c77 /Lib/test | |
parent | cf171a7fbcf4967feb7b4cd01c56250fb3fc8c8a (diff) | |
download | cpython-dd9e3b8736fae1f730d027d5383a2b17c661ce82.zip cpython-dd9e3b8736fae1f730d027d5383a2b17c661ce82.tar.gz cpython-dd9e3b8736fae1f730d027d5383a2b17c661ce82.tar.bz2 |
Correct a failing test when test_import is run after test_coding:
be sure to import a fresh module by removing it from sys.modules
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_coding.py | 11 | ||||
-rw-r--r-- | Lib/test/test_import.py | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Lib/test/test_coding.py b/Lib/test/test_coding.py index 0ff1bdf..b7d4478 100644 --- a/Lib/test/test_coding.py +++ b/Lib/test/test_coding.py @@ -1,5 +1,6 @@ import test.test_support, unittest +from test.test_support import TESTFN import os, sys class CodingTest(unittest.TestCase): @@ -29,8 +30,10 @@ class CodingTest(unittest.TestCase): def test_file_parse(self): # issue1134: all encodings outside latin-1 and utf-8 fail on # multiline strings and long lines (>512 columns) + if TESTFN in sys.modules: + del sys.modules[TESTFN] sys.path.insert(0, ".") - filename = test.test_support.TESTFN+".py" + filename = TESTFN + ".py" f = open(filename, "w") try: f.write("# -*- coding: cp1252 -*-\n") @@ -39,11 +42,11 @@ class CodingTest(unittest.TestCase): f.write("'A very long string %s'\n" % ("X" * 1000)) f.close() - __import__(test.test_support.TESTFN) + __import__(TESTFN) finally: f.close() - os.remove(test.test_support.TESTFN+".py") - os.remove(test.test_support.TESTFN+".pyc") + os.remove(TESTFN+".py") + os.remove(TESTFN+".pyc") sys.path.pop(0) def test_main(): diff --git a/Lib/test/test_import.py b/Lib/test/test_import.py index cdee38d..ffde136 100644 --- a/Lib/test/test_import.py +++ b/Lib/test/test_import.py @@ -54,6 +54,8 @@ class ImportTest(unittest.TestCase): print("b =", b, file=f) f.close() + if TESTFN in sys.modules: + del sys.modules[TESTFN] try: try: mod = __import__(TESTFN) |