summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_email
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-07-23 17:00:29 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2014-07-23 17:00:29 (GMT)
commitf012ba42fe54253378a2784aaf7177aa36be579a (patch)
tree44f904dd1023616f134f1e8f2cddac0185cd313e /Lib/test/test_email
parentc4c464911ab6a65a32b8b2162aa4537003efb87b (diff)
downloadcpython-f012ba42fe54253378a2784aaf7177aa36be579a.zip
cpython-f012ba42fe54253378a2784aaf7177aa36be579a.tar.gz
cpython-f012ba42fe54253378a2784aaf7177aa36be579a.tar.bz2
Issue #22002: Make full use of test discovery in test sub-packages.
Adds `load_package_tests` function to test.support, uses it in test_asyncio, test_email, test_json, test_tools, test_importlib and all test_importlib sub-packages to implement test discovery.
Diffstat (limited to 'Lib/test/test_email')
-rw-r--r--Lib/test/test_email/__init__.py23
-rw-r--r--Lib/test/test_email/__main__.py5
2 files changed, 7 insertions, 21 deletions
diff --git a/Lib/test/test_email/__init__.py b/Lib/test/test_email/__init__.py
index d8896ee..a59775c 100644
--- a/Lib/test/test_email/__init__.py
+++ b/Lib/test/test_email/__init__.py
@@ -1,31 +1,16 @@
import os
import sys
import unittest
-import test.support
import collections
import email
from email.message import Message
from email._policybase import compat32
+from test.support import load_package_tests
from test.test_email import __file__ as landmark
-# Run all tests in package for '-m unittest test.test_email'
-def load_tests(loader, standard_tests, pattern):
- this_dir = os.path.dirname(__file__)
- if pattern is None:
- pattern = "test*"
- package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
- standard_tests.addTests(package_tests)
- return standard_tests
-
-
-# used by regrtest and __main__.
-def test_main():
- here = os.path.dirname(__file__)
- # Unittest mucks with the path, so we have to save and restore
- # it to keep regrtest happy.
- savepath = sys.path[:]
- test.support._run_suite(unittest.defaultTestLoader.discover(here))
- sys.path[:] = savepath
+# Load all tests in package
+def load_tests(*args):
+ return load_package_tests(os.path.dirname(__file__), *args)
# helper code used by a number of test modules.
diff --git a/Lib/test/test_email/__main__.py b/Lib/test/test_email/__main__.py
index 98af9ec..4b14f77 100644
--- a/Lib/test/test_email/__main__.py
+++ b/Lib/test/test_email/__main__.py
@@ -1,3 +1,4 @@
-from test.test_email import test_main
+from test.test_email import load_tests
+import unittest
-test_main()
+unittest.main()