X Tutup
Skip to content

Commit 66f2ea0

Browse files
committed
python#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

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 2 additions & 11 deletions
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

Lines changed: 4 additions & 0 deletions
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()
Lines changed: 1 addition & 1 deletion
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:
Lines changed: 1 addition & 1 deletion
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:
Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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 = [
Lines changed: 1 addition & 1 deletion
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 = [
Lines changed: 1 addition & 1 deletion
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:
Lines changed: 1 addition & 1 deletion
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:

0 commit comments

Comments
 (0)
X Tutup