Skip to content

Commit 66f2ea0

Browse files
committed
#18273: move the tests in Lib/test/json_tests to Lib/test/test_json and make them discoverable by unittest. Patch by Zachary Ware.
1 parent 0d2d2b8 commit 66f2ea0

21 files changed

+25
-44
lines changed

Lib/test/test_json.py

-17
This file was deleted.

Lib/test/json_tests/__init__.py renamed to Lib/test/test_json/__init__.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ def test_cjson(self):
4444

4545
here = os.path.dirname(__file__)
4646

47-
def test_suite():
47+
def load_tests(*args):
4848
suite = additional_tests()
4949
loader = unittest.TestLoader()
5050
for fn in os.listdir(here):
5151
if fn.startswith("test") and fn.endswith(".py"):
52-
modname = "test.json_tests." + fn[:-3]
52+
modname = "test.test_json." + fn[:-3]
5353
__import__(modname)
5454
module = sys.modules[modname]
5555
suite.addTests(loader.loadTestsFromModule(module))
@@ -62,12 +62,3 @@ def additional_tests():
6262
suite.addTest(TestPyTest('test_pyjson'))
6363
suite.addTest(TestCTest('test_cjson'))
6464
return suite
65-
66-
def main():
67-
suite = test_suite()
68-
runner = unittest.TextTestRunner()
69-
runner.run(suite)
70-
71-
if __name__ == '__main__':
72-
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))
73-
main()

Lib/test/test_json/__main__.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import unittest
2+
from test.test_json import load_tests
3+
4+
unittest.main()

Lib/test/json_tests/test_decode.py renamed to Lib/test/test_json/test_decode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import decimal
22
from io import StringIO
33
from collections import OrderedDict
4-
from test.json_tests import PyTest, CTest
4+
from test.test_json import PyTest, CTest
55

66

77
class TestDecode:

Lib/test/json_tests/test_default.py renamed to Lib/test/test_json/test_default.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.json_tests import PyTest, CTest
1+
from test.test_json import PyTest, CTest
22

33

44
class TestDefault:

Lib/test/json_tests/test_dump.py renamed to Lib/test/test_json/test_dump.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from io import StringIO
2-
from test.json_tests import PyTest, CTest
2+
from test.test_json import PyTest, CTest
33

44
from test.support import bigmemtest, _1G
55

Lib/test/json_tests/test_encode_basestring_ascii.py renamed to Lib/test/test_json/test_encode_basestring_ascii.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections import OrderedDict
2-
from test.json_tests import PyTest, CTest
2+
from test.test_json import PyTest, CTest
33

44

55
CASES = [

Lib/test/json_tests/test_fail.py renamed to Lib/test/test_json/test_fail.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.json_tests import PyTest, CTest
1+
from test.test_json import PyTest, CTest
22

33
# 2007-10-05
44
JSONDOCS = [

Lib/test/json_tests/test_float.py renamed to Lib/test/test_json/test_float.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import math
2-
from test.json_tests import PyTest, CTest
2+
from test.test_json import PyTest, CTest
33

44

55
class TestFloat:

Lib/test/json_tests/test_indent.py renamed to Lib/test/test_json/test_indent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import textwrap
22
from io import StringIO
3-
from test.json_tests import PyTest, CTest
3+
from test.test_json import PyTest, CTest
44

55

66
class TestIndent:

Lib/test/json_tests/test_pass1.py renamed to Lib/test/test_json/test_pass1.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.json_tests import PyTest, CTest
1+
from test.test_json import PyTest, CTest
22

33

44
# from http://json.org/JSON_checker/test/pass1.json

Lib/test/json_tests/test_pass2.py renamed to Lib/test/test_json/test_pass2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.json_tests import PyTest, CTest
1+
from test.test_json import PyTest, CTest
22

33

44
# from http://json.org/JSON_checker/test/pass2.json

Lib/test/json_tests/test_pass3.py renamed to Lib/test/test_json/test_pass3.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.json_tests import PyTest, CTest
1+
from test.test_json import PyTest, CTest
22

33

44
# from http://json.org/JSON_checker/test/pass3.json

Lib/test/json_tests/test_recursion.py renamed to Lib/test/test_json/test_recursion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.json_tests import PyTest, CTest
1+
from test.test_json import PyTest, CTest
22

33

44
class JSONTestObject:

Lib/test/json_tests/test_scanstring.py renamed to Lib/test/test_json/test_scanstring.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from test.json_tests import PyTest, CTest
2+
from test.test_json import PyTest, CTest
33

44

55
class TestScanstring:

Lib/test/json_tests/test_separators.py renamed to Lib/test/test_json/test_separators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import textwrap
2-
from test.json_tests import PyTest, CTest
2+
from test.test_json import PyTest, CTest
33

44

55
class TestSeparators:

Lib/test/json_tests/test_speedups.py renamed to Lib/test/test_json/test_speedups.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from test.json_tests import CTest
1+
from test.test_json import CTest
22

33

44
class TestSpeedups(CTest):
File renamed without changes.

Lib/test/json_tests/test_unicode.py renamed to Lib/test/test_json/test_unicode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections import OrderedDict
2-
from test.json_tests import PyTest, CTest
2+
from test.test_json import PyTest, CTest
33

44

55
class TestUnicode:

Makefile.pre.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ LIBSUBDIRS= tkinter tkinter/test tkinter/test/test_tkinter \
10361036
test/namespace_pkgs/module_and_namespace_package/a_test \
10371037
collections concurrent concurrent/futures encodings \
10381038
email email/mime test/test_email test/test_email/data \
1039-
html json test/json_tests http dbm xmlrpc \
1039+
html json test/test_json http dbm xmlrpc \
10401040
sqlite3 sqlite3/test \
10411041
logging csv wsgiref urllib \
10421042
lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \

Misc/NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,9 @@ IDLE
237237
Tests
238238
-----
239239

240+
- Issue #18273: move the tests in Lib/test/json_tests to Lib/test/test_json
241+
and make them discoverable by unittest. Patch by Zachary Ware.
242+
240243
- Fix a fcntl test case on KFreeBSD, Debian #708653 (Petr Salinger).
241244

242245
- Issue #18396: Fix spurious test failure in test_signal on Windows when

0 commit comments

Comments
 (0)