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"},
|
"schema": {"type": "integer"},
|
||||||
"tests": [
|
"tests": [
|
||||||
{
|
{
|
||||||
@@ -9,5 +9,27 @@
|
|||||||
"valid": true
|
"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 = {
|
DEFAULT_TYPES = {
|
||||||
"array" : list, "boolean" : bool, "integer" : numbers.Integral,
|
"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,
|
"string" : basestring,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,8 +152,8 @@ class Draft3Validator(object):
|
|||||||
# bool inherits from int, so ensure bools aren't reported as integers
|
# bool inherits from int, so ensure bools aren't reported as integers
|
||||||
if isinstance(instance, bool):
|
if isinstance(instance, bool):
|
||||||
type = _flatten(type)
|
type = _flatten(type)
|
||||||
have_int = any(issubclass(t, numbers.Integral) for t in type)
|
have_number = any(issubclass(t, numbers.Number) for t in type)
|
||||||
if have_int and bool not in type:
|
if have_number and bool not in type:
|
||||||
return False
|
return False
|
||||||
return isinstance(instance, type)
|
return isinstance(instance, type)
|
||||||
|
|
||||||
|
|||||||
2
tests.py
2
tests.py
@@ -126,7 +126,7 @@ class FormatMixin(object):
|
|||||||
|
|
||||||
@load_json_cases(
|
@load_json_cases(
|
||||||
os.path.join(os.path.dirname(__file__), "json/tests/draft3/"),
|
os.path.join(os.path.dirname(__file__), "json/tests/draft3/"),
|
||||||
# include_optional=("bignum", "format"),
|
include_optional=("bignum",),
|
||||||
)
|
)
|
||||||
class TestDraft3(
|
class TestDraft3(
|
||||||
TestCase, ByteStringMixin, DecimalMixin, AnyTypeMixin, FormatMixin
|
TestCase, ByteStringMixin, DecimalMixin, AnyTypeMixin, FormatMixin
|
||||||
|
|||||||
Reference in New Issue
Block a user