Skip to content

Commit aaf8e31

Browse files
committed
Squashed 'json/' changes from 20fb14bde..3731ed32a
3731ed32a Merge pull request #541 from json-schema-org/unknown-formats 2f2234da4 unknown format requirement is in draft 4 also e12088dbf added tests for unknown formats 3998c8522 Remove dead code from the sanity checker. b038102d9 Add some docstrings for the sanity checker. git-subtree-dir: json git-subtree-split: 3731ed32a5f083d2d75942cf60a05b56ac822bca
1 parent 2f004ca commit aaf8e31

File tree

6 files changed

+227
-5
lines changed

6 files changed

+227
-5
lines changed

bin/jsonschema_suite

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#! /usr/bin/env python3
2-
from __future__ import print_function
3-
from pprint import pformat
42
import argparse
53
import errno
64
import fnmatch
@@ -13,9 +11,6 @@ import textwrap
1311
import unittest
1412
import warnings
1513

16-
if getattr(unittest, "skipIf", None) is None:
17-
unittest.skipIf = lambda cond, msg : lambda fn : fn
18-
1914
try:
2015
import jsonschema.validators
2116
except ImportError:
@@ -33,25 +28,37 @@ with open(os.path.join(ROOT_DIR, "test-schema.json")) as schema:
3328

3429

3530
def files(paths):
31+
"""
32+
Each test file in the provided paths.
33+
"""
3634
for path in paths:
3735
with open(path) as test_file:
3836
yield json.load(test_file)
3937

4038

4139
def groups(paths):
40+
"""
41+
Each test group within each file in the provided paths.
42+
"""
4243
for test_file in files(paths):
4344
for group in test_file:
4445
yield group
4546

4647

4748
def cases(paths):
49+
"""
50+
Each individual test case within all groups within the provided paths.
51+
"""
4852
for test_group in groups(paths):
4953
for test in test_group["tests"]:
5054
test["schema"] = test_group["schema"]
5155
yield test
5256

5357

5458
def collect(root_dir):
59+
"""
60+
All of the test file paths within the given root directory, recursively.
61+
"""
5562
for root, _, files in os.walk(root_dir):
5663
for filename in fnmatch.filter(files, "*.json"):
5764
yield os.path.join(root, filename)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[
2+
{
3+
"description": "unknown format",
4+
"schema": { "format": "unknown" },
5+
"tests": [
6+
{
7+
"description": "unknown formats ignore integers",
8+
"data": 12,
9+
"valid": true
10+
},
11+
{
12+
"description": "unknown formats ignore floats",
13+
"data": 13.7,
14+
"valid": true
15+
},
16+
{
17+
"description": "unknown formats ignore objects",
18+
"data": {},
19+
"valid": true
20+
},
21+
{
22+
"description": "unknown formats ignore arrays",
23+
"data": [],
24+
"valid": true
25+
},
26+
{
27+
"description": "unknown formats ignore booleans",
28+
"data": false,
29+
"valid": true
30+
},
31+
{
32+
"description": "unknown formats ignore nulls",
33+
"data": null,
34+
"valid": true
35+
},
36+
{
37+
"description": "unknown formats ignore strings",
38+
"data": "string",
39+
"valid": true
40+
}
41+
]
42+
}
43+
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[
2+
{
3+
"description": "unknown format",
4+
"schema": { "format": "unknown" },
5+
"tests": [
6+
{
7+
"description": "unknown formats ignore integers",
8+
"data": 12,
9+
"valid": true
10+
},
11+
{
12+
"description": "unknown formats ignore floats",
13+
"data": 13.7,
14+
"valid": true
15+
},
16+
{
17+
"description": "unknown formats ignore objects",
18+
"data": {},
19+
"valid": true
20+
},
21+
{
22+
"description": "unknown formats ignore arrays",
23+
"data": [],
24+
"valid": true
25+
},
26+
{
27+
"description": "unknown formats ignore booleans",
28+
"data": false,
29+
"valid": true
30+
},
31+
{
32+
"description": "unknown formats ignore nulls",
33+
"data": null,
34+
"valid": true
35+
},
36+
{
37+
"description": "unknown formats ignore strings",
38+
"data": "string",
39+
"valid": true
40+
}
41+
]
42+
}
43+
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[
2+
{
3+
"description": "unknown format",
4+
"schema": { "format": "unknown" },
5+
"tests": [
6+
{
7+
"description": "unknown formats ignore integers",
8+
"data": 12,
9+
"valid": true
10+
},
11+
{
12+
"description": "unknown formats ignore floats",
13+
"data": 13.7,
14+
"valid": true
15+
},
16+
{
17+
"description": "unknown formats ignore objects",
18+
"data": {},
19+
"valid": true
20+
},
21+
{
22+
"description": "unknown formats ignore arrays",
23+
"data": [],
24+
"valid": true
25+
},
26+
{
27+
"description": "unknown formats ignore booleans",
28+
"data": false,
29+
"valid": true
30+
},
31+
{
32+
"description": "unknown formats ignore nulls",
33+
"data": null,
34+
"valid": true
35+
},
36+
{
37+
"description": "unknown formats ignore strings",
38+
"data": "string",
39+
"valid": true
40+
}
41+
]
42+
}
43+
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[
2+
{
3+
"description": "unknown format",
4+
"schema": { "format": "unknown" },
5+
"tests": [
6+
{
7+
"description": "unknown formats ignore integers",
8+
"data": 12,
9+
"valid": true
10+
},
11+
{
12+
"description": "unknown formats ignore floats",
13+
"data": 13.7,
14+
"valid": true
15+
},
16+
{
17+
"description": "unknown formats ignore objects",
18+
"data": {},
19+
"valid": true
20+
},
21+
{
22+
"description": "unknown formats ignore arrays",
23+
"data": [],
24+
"valid": true
25+
},
26+
{
27+
"description": "unknown formats ignore booleans",
28+
"data": false,
29+
"valid": true
30+
},
31+
{
32+
"description": "unknown formats ignore nulls",
33+
"data": null,
34+
"valid": true
35+
},
36+
{
37+
"description": "unknown formats ignore strings",
38+
"data": "string",
39+
"valid": true
40+
}
41+
]
42+
}
43+
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[
2+
{
3+
"description": "unknown format",
4+
"schema": { "format": "unknown" },
5+
"tests": [
6+
{
7+
"description": "unknown formats ignore integers",
8+
"data": 12,
9+
"valid": true
10+
},
11+
{
12+
"description": "unknown formats ignore floats",
13+
"data": 13.7,
14+
"valid": true
15+
},
16+
{
17+
"description": "unknown formats ignore objects",
18+
"data": {},
19+
"valid": true
20+
},
21+
{
22+
"description": "unknown formats ignore arrays",
23+
"data": [],
24+
"valid": true
25+
},
26+
{
27+
"description": "unknown formats ignore booleans",
28+
"data": false,
29+
"valid": true
30+
},
31+
{
32+
"description": "unknown formats ignore nulls",
33+
"data": null,
34+
"valid": true
35+
},
36+
{
37+
"description": "unknown formats ignore strings",
38+
"data": "string",
39+
"valid": true
40+
}
41+
]
42+
}
43+
]

0 commit comments

Comments
 (0)