]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
I found that when run as a script, this test suite ran its tests
authorGuido van Rossum <guido@python.org>
Fri, 7 Dec 2001 21:07:08 +0000 (21:07 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 7 Dec 2001 21:07:08 +0000 (21:07 +0000)
twice!  Fixed this by avoiding the import of test_email, which loads
the module a second time in that situation, and fiddled the __main__
section to resemble other test suites using unittest.

Lib/test/test_email.py

index 2e7cc00883c1ff45363bfd50490a63bf99dc886e..ddc36f37a7d90e17310ce708f94584db83e12f6a 100644 (file)
@@ -23,8 +23,7 @@ from email import Errors
 from email import Encoders
 from email import Iterators
 
-import test_email
-from test_support import findfile
+from test_support import findfile, __file__ as test_support_file
 
 
 NL = '\n'
@@ -34,7 +33,7 @@ SPACE = ' '
 
 \f
 def openfile(filename):
-    path = os.path.join(os.path.dirname(test_email.__file__), 'data', filename)
+    path = os.path.join(os.path.dirname(test_support_file), 'data', filename)
     return open(path)
 
 
@@ -1041,8 +1040,9 @@ def suite():
 
 
 \f
-if __name__ == '__main__':
-    unittest.main(defaultTest='suite')
-else:
+def test_main():
     from test_support import run_suite
     run_suite(suite())
+
+if __name__ == '__main__':
+    test_main()