[Python-3000-checkins] r59008 - python/branches/py3k/Lib/test/test_coding.py python/branches/py3k/Lib/test/test_import.py

amaury.forgeotdarc python-3000-checkins at python.org
Fri Nov 16 01:56:23 CET 2007


Author: amaury.forgeotdarc
Date: Fri Nov 16 01:56:23 2007
New Revision: 59008

Modified:
   python/branches/py3k/Lib/test/test_coding.py
   python/branches/py3k/Lib/test/test_import.py
Log:
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


Modified: python/branches/py3k/Lib/test/test_coding.py
==============================================================================
--- python/branches/py3k/Lib/test/test_coding.py	(original)
+++ python/branches/py3k/Lib/test/test_coding.py	Fri Nov 16 01:56:23 2007
@@ -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 @@
     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 @@
             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():

Modified: python/branches/py3k/Lib/test/test_import.py
==============================================================================
--- python/branches/py3k/Lib/test/test_import.py	(original)
+++ python/branches/py3k/Lib/test/test_import.py	Fri Nov 16 01:56:23 2007
@@ -54,6 +54,8 @@
             print("b =", b, file=f)
             f.close()
 
+            if TESTFN in sys.modules:
+                del sys.modules[TESTFN]
             try:
                 try:
                     mod = __import__(TESTFN)


More information about the Python-3000-checkins mailing list