summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_json/__init__.py
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_json/__init__.py
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_json/__init__.py')
-rw-r--r--Lib/test/test_json/__init__.py19
1 files changed, 4 insertions, 15 deletions
diff --git a/Lib/test/test_json/__init__.py b/Lib/test/test_json/__init__.py
index f994f9b..2cf1032 100644
--- a/Lib/test/test_json/__init__.py
+++ b/Lib/test/test_json/__init__.py
@@ -42,23 +42,12 @@ class TestCTest(CTest):
'_json')
-here = os.path.dirname(__file__)
-
-def load_tests(*args):
- suite = additional_tests()
- loader = unittest.TestLoader()
- for fn in os.listdir(here):
- if fn.startswith("test") and fn.endswith(".py"):
- modname = "test.test_json." + fn[:-3]
- __import__(modname)
- module = sys.modules[modname]
- suite.addTests(loader.loadTestsFromModule(module))
- return suite
-
-def additional_tests():
+def load_tests(loader, _, pattern):
suite = unittest.TestSuite()
for mod in (json, json.encoder, json.decoder):
suite.addTest(doctest.DocTestSuite(mod))
suite.addTest(TestPyTest('test_pyjson'))
suite.addTest(TestCTest('test_cjson'))
- return suite
+
+ pkg_dir = os.path.dirname(__file__)
+ return support.load_package_tests(pkg_dir, loader, suite, pattern)