Skip to content

Commit

Permalink
Merge pull request #664 from santhosh-tekuri/empty-tokens
Browse files Browse the repository at this point in the history
ref: test empty tokens in json-pointer
  • Loading branch information
gregsdennis authored Apr 21, 2023
2 parents 8025fc0 + e4bceb1 commit 6afa9b3
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 1 deletion.
14 changes: 14 additions & 0 deletions bin/jsonschema_suite
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,13 @@ class SanityTests(unittest.TestCase):
"title",
"type",
"uniqueItems",

# Technically this is wrong, $comment doesn't exist in this
# draft, but the point of this test is to detect mistakes by,
# test authors, whereas the point of the $comment keyword is
# to just standardize a place for a comment, so it's not a
# mistake to use it in earlier drafts in tests per se.
"$comment",
},
"draft3": {
"$ref",
Expand Down Expand Up @@ -528,6 +535,13 @@ class SanityTests(unittest.TestCase):
"title",
"type",
"uniqueItems",

# Technically this is wrong, $comment doesn't exist in this
# draft, but the point of this test is to detect mistakes by,
# test authors, whereas the point of the $comment keyword is
# to just standardize a place for a comment, so it's not a
# mistake to use it in earlier drafts in tests per se.
"$comment",
},
}

Expand Down
29 changes: 29 additions & 0 deletions tests/draft-next/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -1026,5 +1026,34 @@
"valid": false
}
]
},
{
"description": "empty tokens in $ref json-pointer",
"schema": {
"$defs": {
"": {
"$defs": {
"": { "type": "number" }
}
}
},
"allOf": [
{
"$ref": "#/$defs//$defs/"
}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
29 changes: 29 additions & 0 deletions tests/draft2019-09/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -1026,5 +1026,34 @@
"valid": false
}
]
},
{
"description": "empty tokens in $ref json-pointer",
"schema": {
"$defs": {
"": {
"$defs": {
"": { "type": "number" }
}
}
},
"allOf": [
{
"$ref": "#/$defs//$defs/"
}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
29 changes: 29 additions & 0 deletions tests/draft2020-12/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -1026,5 +1026,34 @@
"valid": false
}
]
},
{
"description": "empty tokens in $ref json-pointer",
"schema": {
"$defs": {
"": {
"$defs": {
"": { "type": "number" }
}
}
},
"allOf": [
{
"$ref": "#/$defs//$defs/"
}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
29 changes: 29 additions & 0 deletions tests/draft4/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -559,5 +559,34 @@
"valid": false
}
]
},
{
"description": "empty tokens in $ref json-pointer",
"schema": {
"definitions": {
"": {
"definitions": {
"": { "type": "number" }
}
}
},
"allOf": [
{
"$ref": "#/definitions//definitions/"
}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
29 changes: 29 additions & 0 deletions tests/draft6/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -869,5 +869,34 @@
"valid": false
}
]
},
{
"description": "empty tokens in $ref json-pointer",
"schema": {
"definitions": {
"": {
"definitions": {
"": { "type": "number" }
}
}
},
"allOf": [
{
"$ref": "#/definitions//definitions/"
}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
29 changes: 29 additions & 0 deletions tests/draft7/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -983,5 +983,34 @@
"valid": false
}
]
},
{
"description": "empty tokens in $ref json-pointer",
"schema": {
"definitions": {
"": {
"definitions": {
"": { "type": "number" }
}
}
},
"allOf": [
{
"$ref": "#/definitions//definitions/"
}
]
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ skipsdist = True

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

0 comments on commit 6afa9b3

Please sign in to comment.