test_main(): Added this so the test can actually get run under the
regrtest framework. Keep the original standalone-unittest
scaffolding (i.e. suite() and __main__).
diff --git a/Lib/test/test_email.py b/Lib/test/test_email.py
index 1322246..efbe271 100644
--- a/Lib/test/test_email.py
+++ b/Lib/test/test_email.py
@@ -29,8 +29,10 @@
from email import base64MIME
from email import quopriMIME
+import test_support
from test_support import findfile, __file__ as test_support_file
+
NL = '\n'
EMPTYSTRING = ''
SPACE = ' '
@@ -1573,30 +1575,23 @@
+def _testclasses():
+ mod = sys.modules[__name__]
+ return [getattr(mod, name) for name in dir(mod) if name.startswith('Test')]
+
+
def suite():
suite = unittest.TestSuite()
- suite.addTest(unittest.makeSuite(TestMessageAPI))
- suite.addTest(unittest.makeSuite(TestEncoders))
- suite.addTest(unittest.makeSuite(TestLongHeaders))
- suite.addTest(unittest.makeSuite(TestFromMangling))
- suite.addTest(unittest.makeSuite(TestMIMEAudio))
- suite.addTest(unittest.makeSuite(TestMIMEImage))
- suite.addTest(unittest.makeSuite(TestMIMEText))
- suite.addTest(unittest.makeSuite(TestMultipartMixed))
- suite.addTest(unittest.makeSuite(TestNonConformant))
- suite.addTest(unittest.makeSuite(TestRFC2047))
- suite.addTest(unittest.makeSuite(TestMIMEMessage))
- suite.addTest(unittest.makeSuite(TestIdempotent))
- suite.addTest(unittest.makeSuite(TestMiscellaneous))
- suite.addTest(unittest.makeSuite(TestIterators))
- suite.addTest(unittest.makeSuite(TestParsers))
- suite.addTest(unittest.makeSuite(TestBase64))
- suite.addTest(unittest.makeSuite(TestQuopri))
- suite.addTest(unittest.makeSuite(TestHeader))
- suite.addTest(unittest.makeSuite(TestCharset))
+ for testclass in _testclasses():
+ suite.addTest(unittest.makeSuite(testclass))
return suite
+def test_main():
+ for testclass in _testclasses():
+ test_support.run_unittest(testclass)
+
+
if __name__ == '__main__':
unittest.main(defaultTest='suite')
diff --git a/Lib/test/test_email_codecs.py b/Lib/test/test_email_codecs.py
index d0451d1..3a133e8 100644
--- a/Lib/test/test_email_codecs.py
+++ b/Lib/test/test_email_codecs.py
@@ -2,7 +2,7 @@
# email package unit tests for (optional) Asian codecs
import unittest
-from test_support import TestSkipped
+import test_support
from email.Charset import Charset
from email.Header import Header, decode_header
@@ -12,7 +12,7 @@
try:
unicode('foo', 'japanese.iso-2022-jp')
except LookupError:
- raise TestSkipped, 'Optional Japanese codecs not installed'
+ raise test_support.TestSkipped, 'Optional Japanese codecs not installed'
@@ -46,6 +46,10 @@
return suite
+def test_main():
+ test_support.run_unittest(TestEmailAsianCodecs)
+
+
if __name__ == '__main__':
unittest.main(defaultTest='suite')