Enable bignum tests, add two more, and correct number as well.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{
|
||||
"description": "support for bignums",
|
||||
"description": "integer",
|
||||
"schema": {"type": "integer"},
|
||||
"tests": [
|
||||
{
|
||||
@@ -9,5 +9,27 @@
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "number",
|
||||
"schema": {"type": "number"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is a number",
|
||||
"data": 98249283749234923498293171823948729348710298301928331,
|
||||
"valid": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "string",
|
||||
"schema": {"type": "string"},
|
||||
"tests": [
|
||||
{
|
||||
"description": "a bignum is not a string",
|
||||
"data": 98249283749234923498293171823948729348710298301928331,
|
||||
"valid": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -127,7 +127,7 @@ class Draft3Validator(object):
|
||||
|
||||
DEFAULT_TYPES = {
|
||||
"array" : list, "boolean" : bool, "integer" : numbers.Integral,
|
||||
"null" : type(None), "number" : (int, float), "object" : dict,
|
||||
"null" : type(None), "number" : numbers.Number, "object" : dict,
|
||||
"string" : basestring,
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ class Draft3Validator(object):
|
||||
# bool inherits from int, so ensure bools aren't reported as integers
|
||||
if isinstance(instance, bool):
|
||||
type = _flatten(type)
|
||||
have_int = any(issubclass(t, numbers.Integral) for t in type)
|
||||
if have_int and bool not in type:
|
||||
have_number = any(issubclass(t, numbers.Number) for t in type)
|
||||
if have_number and bool not in type:
|
||||
return False
|
||||
return isinstance(instance, type)
|
||||
|
||||
|
||||
2
tests.py
2
tests.py
@@ -126,7 +126,7 @@ class FormatMixin(object):
|
||||
|
||||
@load_json_cases(
|
||||
os.path.join(os.path.dirname(__file__), "json/tests/draft3/"),
|
||||
# include_optional=("bignum", "format"),
|
||||
include_optional=("bignum",),
|
||||
)
|
||||
class TestDraft3(
|
||||
TestCase, ByteStringMixin, DecimalMixin, AnyTypeMixin, FormatMixin
|
||||
|
||||
Reference in New Issue
Block a user