Skip to content

Commit 6afa9b3

Browse files
authored
Merge pull request #664 from santhosh-tekuri/empty-tokens
ref: test empty tokens in json-pointer
2 parents 8025fc0 + e4bceb1 commit 6afa9b3

File tree

8 files changed

+189
-1
lines changed

8 files changed

+189
-1
lines changed

bin/jsonschema_suite

+14
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,13 @@ class SanityTests(unittest.TestCase):
498498
"title",
499499
"type",
500500
"uniqueItems",
501+
502+
# Technically this is wrong, $comment doesn't exist in this
503+
# draft, but the point of this test is to detect mistakes by,
504+
# test authors, whereas the point of the $comment keyword is
505+
# to just standardize a place for a comment, so it's not a
506+
# mistake to use it in earlier drafts in tests per se.
507+
"$comment",
501508
},
502509
"draft3": {
503510
"$ref",
@@ -528,6 +535,13 @@ class SanityTests(unittest.TestCase):
528535
"title",
529536
"type",
530537
"uniqueItems",
538+
539+
# Technically this is wrong, $comment doesn't exist in this
540+
# draft, but the point of this test is to detect mistakes by,
541+
# test authors, whereas the point of the $comment keyword is
542+
# to just standardize a place for a comment, so it's not a
543+
# mistake to use it in earlier drafts in tests per se.
544+
"$comment",
531545
},
532546
}
533547

tests/draft-next/ref.json

+29
Original file line numberDiff line numberDiff line change
@@ -1026,5 +1026,34 @@
10261026
"valid": false
10271027
}
10281028
]
1029+
},
1030+
{
1031+
"description": "empty tokens in $ref json-pointer",
1032+
"schema": {
1033+
"$defs": {
1034+
"": {
1035+
"$defs": {
1036+
"": { "type": "number" }
1037+
}
1038+
}
1039+
},
1040+
"allOf": [
1041+
{
1042+
"$ref": "#/$defs//$defs/"
1043+
}
1044+
]
1045+
},
1046+
"tests": [
1047+
{
1048+
"description": "number is valid",
1049+
"data": 1,
1050+
"valid": true
1051+
},
1052+
{
1053+
"description": "non-number is invalid",
1054+
"data": "a",
1055+
"valid": false
1056+
}
1057+
]
10291058
}
10301059
]

tests/draft2019-09/ref.json

+29
Original file line numberDiff line numberDiff line change
@@ -1026,5 +1026,34 @@
10261026
"valid": false
10271027
}
10281028
]
1029+
},
1030+
{
1031+
"description": "empty tokens in $ref json-pointer",
1032+
"schema": {
1033+
"$defs": {
1034+
"": {
1035+
"$defs": {
1036+
"": { "type": "number" }
1037+
}
1038+
}
1039+
},
1040+
"allOf": [
1041+
{
1042+
"$ref": "#/$defs//$defs/"
1043+
}
1044+
]
1045+
},
1046+
"tests": [
1047+
{
1048+
"description": "number is valid",
1049+
"data": 1,
1050+
"valid": true
1051+
},
1052+
{
1053+
"description": "non-number is invalid",
1054+
"data": "a",
1055+
"valid": false
1056+
}
1057+
]
10291058
}
10301059
]

tests/draft2020-12/ref.json

+29
Original file line numberDiff line numberDiff line change
@@ -1026,5 +1026,34 @@
10261026
"valid": false
10271027
}
10281028
]
1029+
},
1030+
{
1031+
"description": "empty tokens in $ref json-pointer",
1032+
"schema": {
1033+
"$defs": {
1034+
"": {
1035+
"$defs": {
1036+
"": { "type": "number" }
1037+
}
1038+
}
1039+
},
1040+
"allOf": [
1041+
{
1042+
"$ref": "#/$defs//$defs/"
1043+
}
1044+
]
1045+
},
1046+
"tests": [
1047+
{
1048+
"description": "number is valid",
1049+
"data": 1,
1050+
"valid": true
1051+
},
1052+
{
1053+
"description": "non-number is invalid",
1054+
"data": "a",
1055+
"valid": false
1056+
}
1057+
]
10291058
}
10301059
]

tests/draft4/ref.json

+29
Original file line numberDiff line numberDiff line change
@@ -559,5 +559,34 @@
559559
"valid": false
560560
}
561561
]
562+
},
563+
{
564+
"description": "empty tokens in $ref json-pointer",
565+
"schema": {
566+
"definitions": {
567+
"": {
568+
"definitions": {
569+
"": { "type": "number" }
570+
}
571+
}
572+
},
573+
"allOf": [
574+
{
575+
"$ref": "#/definitions//definitions/"
576+
}
577+
]
578+
},
579+
"tests": [
580+
{
581+
"description": "number is valid",
582+
"data": 1,
583+
"valid": true
584+
},
585+
{
586+
"description": "non-number is invalid",
587+
"data": "a",
588+
"valid": false
589+
}
590+
]
562591
}
563592
]

tests/draft6/ref.json

+29
Original file line numberDiff line numberDiff line change
@@ -869,5 +869,34 @@
869869
"valid": false
870870
}
871871
]
872+
},
873+
{
874+
"description": "empty tokens in $ref json-pointer",
875+
"schema": {
876+
"definitions": {
877+
"": {
878+
"definitions": {
879+
"": { "type": "number" }
880+
}
881+
}
882+
},
883+
"allOf": [
884+
{
885+
"$ref": "#/definitions//definitions/"
886+
}
887+
]
888+
},
889+
"tests": [
890+
{
891+
"description": "number is valid",
892+
"data": 1,
893+
"valid": true
894+
},
895+
{
896+
"description": "non-number is invalid",
897+
"data": "a",
898+
"valid": false
899+
}
900+
]
872901
}
873902
]

tests/draft7/ref.json

+29
Original file line numberDiff line numberDiff line change
@@ -983,5 +983,34 @@
983983
"valid": false
984984
}
985985
]
986+
},
987+
{
988+
"description": "empty tokens in $ref json-pointer",
989+
"schema": {
990+
"definitions": {
991+
"": {
992+
"definitions": {
993+
"": { "type": "number" }
994+
}
995+
}
996+
},
997+
"allOf": [
998+
{
999+
"$ref": "#/definitions//definitions/"
1000+
}
1001+
]
1002+
},
1003+
"tests": [
1004+
{
1005+
"description": "number is valid",
1006+
"data": 1,
1007+
"valid": true
1008+
},
1009+
{
1010+
"description": "non-number is invalid",
1011+
"data": "a",
1012+
"valid": false
1013+
}
1014+
]
9861015
}
9871016
]

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ skipsdist = True
55

66
[testenv:sanity]
77
# used just for validating the structure of the test case files themselves
8-
deps = jsonschema==4.17.3
8+
deps = jsonschema==4.18.0a4
99
commands = {envpython} bin/jsonschema_suite check

0 commit comments

Comments
 (0)