Skip to content

Commit

Permalink
And now fix enum.
Browse files Browse the repository at this point in the history
Closes: #575.
  • Loading branch information
Julian committed Aug 2, 2019
1 parent 1598940 commit 27eb5d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 61 deletions.
7 changes: 6 additions & 1 deletion jsonschema/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
extras_msg,
find_additional_properties,
types_msg,
unbool,
uniq,
)
from jsonschema.exceptions import FormatError, ValidationError
Expand Down Expand Up @@ -240,7 +241,11 @@ def dependencies(validator, dependencies, instance, schema):


def enum(validator, enums, instance, schema):
if instance not in enums:
if instance == 0 or instance == 1:
unbooled = unbool(instance)
if all(unbooled != unbool(each) for each in enums):
yield ValidationError("%r is not one of %r" % (instance, enums))
elif instance not in enums:
yield ValidationError("%r is not one of %r" % (instance, enums))


Expand Down
60 changes: 0 additions & 60 deletions jsonschema/tests/test_jsonschema_test_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,6 @@ def bug(issue=None):
skip=lambda test: (
narrow_unicode_build(test)
or missing_format(draft4_format_checker)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with true does not match 1",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with false does not match 0",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with 1 does not match true",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with 0 does not match false",
)(test)
or skip(
message=bug(),
subject="ref",
Expand Down Expand Up @@ -174,26 +154,6 @@ def bug(issue=None):
skip=lambda test: (
narrow_unicode_build(test)
or missing_format(draft6_format_checker)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with true does not match 1",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with false does not match 0",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with 1 does not match true",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with 0 does not match false",
)(test)
or skip(
message=bug(),
subject="ref",
Expand Down Expand Up @@ -247,26 +207,6 @@ def bug(issue=None):
skip=lambda test: (
narrow_unicode_build(test)
or missing_format(draft7_format_checker)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with true does not match 1",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with false does not match 0",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with 1 does not match true",
)(test)
or skip(
message=bug(575),
subject="enum",
case_description="enum with 0 does not match false",
)(test)
or skip(
message=bug(),
subject="ref",
Expand Down

0 comments on commit 27eb5d2

Please sign in to comment.