Skip to content

ref: test empty tokens in json-pointer #664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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