diff --git a/json/tests/draft3/optional/bignum.json b/json/tests/draft3/optional/bignum.json index 47a87d9..e37cf86 100644 --- a/json/tests/draft3/optional/bignum.json +++ b/json/tests/draft3/optional/bignum.json @@ -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 + } + ] } ] diff --git a/jsonschema.py b/jsonschema.py index 6aac2dc..5ab6260 100644 --- a/jsonschema.py +++ b/jsonschema.py @@ -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) diff --git a/tests.py b/tests.py index 42c288d..5378939 100644 --- a/tests.py +++ b/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