Skip to content

Commit b82b18c

Browse files
committed
Assert case descriptions are also unique in sanity checks.
The reason we do this for tests is to allow implementers to use test descriptions as unique identifiers, and also because there's a small chance a duplicate description is a copy paste error, or some other test bug. The same reasoning applies to cases. 0da2aaa is another good reason (which in theory applies to both test cases and individual tests) where a case was accidentally duplicated a second time during backporting (where it was already present). See e.g. the first file fixed here, where descriptions should really indicate what validator is being tested for clarity. We don't however check directly for schema duplication in cases, as one could imagine distinct scenarios being tested with the same underlying schema. Fixing further files will be done in successive commits.
1 parent d3d0822 commit b82b18c

File tree

7 files changed

+33
-25
lines changed

7 files changed

+33
-25
lines changed

bin/jsonschema_suite

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,15 @@ class SanityTests(unittest.TestCase):
141141
)
142142
print(f"Found {count} tests.")
143143

144-
def test_all_descriptions_are_unique(self):
144+
def test_all_case_descriptions_are_unique(self):
145+
"""
146+
All cases have unique descriptions in their files.
147+
"""
148+
for path, cases in files(self.test_files):
149+
with self.subTest(path=path):
150+
self.assertUnique(case["description"] for case in cases)
151+
152+
def test_all_test_descriptions_are_unique(self):
145153
"""
146154
All test cases have unique test descriptions in their tests.
147155
"""

tests/draft-next/optional/ecmascript-regex.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
]
343343
},
344344
{
345-
"description": "unicode characters do not match ascii ranges",
345+
"description": "pattern with ASCII ranges",
346346
"schema": { "pattern": "[a-z]cole" },
347347
"tests": [
348348
{
@@ -395,7 +395,7 @@
395395
]
396396
},
397397
{
398-
"description": "unicode digits are more than 0 through 9",
398+
"description": "pattern with non-ASCII digits",
399399
"schema": { "pattern": "^\\p{digit}+$" },
400400
"tests": [
401401
{
@@ -480,7 +480,7 @@
480480
]
481481
},
482482
{
483-
"description": "unicode characters do not match ascii ranges",
483+
"description": "patternProperties with ASCII ranges",
484484
"schema": {
485485
"type": "object",
486486
"patternProperties": {
@@ -534,7 +534,7 @@
534534
]
535535
},
536536
{
537-
"description": "unicode digits are more than 0 through 9",
537+
"description": "patternProperties with non-ASCII digits",
538538
"schema": {
539539
"type": "object",
540540
"patternProperties": {

tests/draft2019-09/optional/ecmascript-regex.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
]
343343
},
344344
{
345-
"description": "unicode characters do not match ascii ranges",
345+
"description": "pattern with ASCII ranges",
346346
"schema": { "pattern": "[a-z]cole" },
347347
"tests": [
348348
{
@@ -384,7 +384,7 @@
384384
]
385385
},
386386
{
387-
"description": "unicode digits are more than 0 through 9",
387+
"description": "pattern with non-ASCII digits",
388388
"schema": { "pattern": "^\\p{digit}+$" },
389389
"tests": [
390390
{
@@ -469,7 +469,7 @@
469469
]
470470
},
471471
{
472-
"description": "unicode characters do not match ascii ranges",
472+
"description": "patternProperties with ASCII ranges",
473473
"schema": {
474474
"type": "object",
475475
"patternProperties": {
@@ -523,7 +523,7 @@
523523
]
524524
},
525525
{
526-
"description": "unicode digits are more than 0 through 9",
526+
"description": "patternProperties with non-ASCII digits",
527527
"schema": {
528528
"type": "object",
529529
"patternProperties": {

tests/draft2020-12/optional/ecmascript-regex.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
]
343343
},
344344
{
345-
"description": "unicode characters do not match ascii ranges",
345+
"description": "pattern with ASCII ranges",
346346
"schema": { "pattern": "[a-z]cole" },
347347
"tests": [
348348
{
@@ -395,7 +395,7 @@
395395
]
396396
},
397397
{
398-
"description": "unicode digits are more than 0 through 9",
398+
"description": "pattern with non-ASCII digits",
399399
"schema": { "pattern": "^\\p{digit}+$" },
400400
"tests": [
401401
{
@@ -480,7 +480,7 @@
480480
]
481481
},
482482
{
483-
"description": "unicode characters do not match ascii ranges",
483+
"description": "patternProperties with ASCII ranges",
484484
"schema": {
485485
"type": "object",
486486
"patternProperties": {
@@ -534,7 +534,7 @@
534534
]
535535
},
536536
{
537-
"description": "unicode digits are more than 0 through 9",
537+
"description": "patternProperties with non-ASCII digits",
538538
"schema": {
539539
"type": "object",
540540
"patternProperties": {

tests/draft4/optional/ecmascript-regex.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
]
343343
},
344344
{
345-
"description": "unicode characters do not match ascii ranges",
345+
"description": "pattern with ASCII ranges",
346346
"schema": { "pattern": "[a-z]cole" },
347347
"tests": [
348348
{
@@ -384,7 +384,7 @@
384384
]
385385
},
386386
{
387-
"description": "unicode digits are more than 0 through 9",
387+
"description": "pattern with non-ASCII digits",
388388
"schema": { "pattern": "^\\p{digit}+$" },
389389
"tests": [
390390
{
@@ -469,7 +469,7 @@
469469
]
470470
},
471471
{
472-
"description": "unicode characters do not match ascii ranges",
472+
"description": "patternProperties with ASCII ranges",
473473
"schema": {
474474
"type": "object",
475475
"patternProperties": {
@@ -523,7 +523,7 @@
523523
]
524524
},
525525
{
526-
"description": "unicode digits are more than 0 through 9",
526+
"description": "patternProperties with non-ASCII digits",
527527
"schema": {
528528
"type": "object",
529529
"patternProperties": {

tests/draft6/optional/ecmascript-regex.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
]
343343
},
344344
{
345-
"description": "unicode characters do not match ascii ranges",
345+
"description": "pattern with ASCII ranges",
346346
"schema": { "pattern": "[a-z]cole" },
347347
"tests": [
348348
{
@@ -384,7 +384,7 @@
384384
]
385385
},
386386
{
387-
"description": "unicode digits are more than 0 through 9",
387+
"description": "pattern with non-ASCII digits",
388388
"schema": { "pattern": "^\\p{digit}+$" },
389389
"tests": [
390390
{
@@ -469,7 +469,7 @@
469469
]
470470
},
471471
{
472-
"description": "unicode characters do not match ascii ranges",
472+
"description": "patternProperties with ASCII ranges",
473473
"schema": {
474474
"type": "object",
475475
"patternProperties": {
@@ -523,7 +523,7 @@
523523
]
524524
},
525525
{
526-
"description": "unicode digits are more than 0 through 9",
526+
"description": "patternProperties with non-ASCII digits",
527527
"schema": {
528528
"type": "object",
529529
"patternProperties": {

tests/draft7/optional/ecmascript-regex.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
]
343343
},
344344
{
345-
"description": "unicode characters do not match ascii ranges",
345+
"description": "pattern with ASCII ranges",
346346
"schema": { "pattern": "[a-z]cole" },
347347
"tests": [
348348
{
@@ -384,7 +384,7 @@
384384
]
385385
},
386386
{
387-
"description": "unicode digits are more than 0 through 9",
387+
"description": "pattern with non-ASCII digits",
388388
"schema": { "pattern": "^\\p{digit}+$" },
389389
"tests": [
390390
{
@@ -469,7 +469,7 @@
469469
]
470470
},
471471
{
472-
"description": "unicode characters do not match ascii ranges",
472+
"description": "patternProperties with ASCII ranges",
473473
"schema": {
474474
"type": "object",
475475
"patternProperties": {
@@ -523,7 +523,7 @@
523523
]
524524
},
525525
{
526-
"description": "unicode digits are more than 0 through 9",
526+
"description": "patternProperties with non-ASCII digits",
527527
"schema": {
528528
"type": "object",
529529
"patternProperties": {

0 commit comments

Comments
 (0)