-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix const and add const to error message
- Loading branch information
Showing
4 changed files
with
29 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
import pytest | ||
|
||
from fastjsonschema import JsonSchemaException | ||
|
||
@pytest.mark.parametrize('value', ( | ||
'foo', | ||
42, | ||
False, | ||
[1, 2, 3] | ||
|
||
@pytest.mark.parametrize('value, testError', ( | ||
('foo', False), | ||
(42, False), | ||
(False, False), | ||
([1, 2, 3], False), | ||
('\'"', False), | ||
('foo', True), | ||
('\'"', False), | ||
)) | ||
def test_const(asserter, value): | ||
def test_const(asserter, value, testError): | ||
const = expected = value | ||
if testError: | ||
const = 'x' | ||
expected = JsonSchemaException('data must be same as const definition: x', value='{data}', name='data', definition='{definition}', rule='const') | ||
|
||
asserter({ | ||
'$schema': 'http://json-schema.org/draft-06/schema', | ||
'const': value, | ||
}, value, value) | ||
'const': const, | ||
}, value, expected) |