Skip to content

Commit fc8c98b

Browse files
committed
Fix #59, numeric merging bug
1 parent 61e0cdf commit fc8c98b

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
#### 0.17.1 - 2020-07-16
4+
- fixed an internal bug where results incorrectly depended on iteration order (#59)
5+
36
#### 0.17.0 - 2020-07-16
47
- Adds a `custom_formats` keyword argument to `from_schema()`, so that you can
58
specify a strategy to generate strings for custom formats like credit card numbers.

src/hypothesis_jsonschema/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The only public API is `from_schema`; check the docstring for details.
44
"""
55

6-
__version__ = "0.17.0"
6+
__version__ = "0.17.1"
77
__all__ = ["from_schema"]
88

99
from ._from_schema import from_schema

src/hypothesis_jsonschema/_canonicalise.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,11 @@ def merged(schemas: List[Any]) -> Optional[Schema]:
674674

675675
if "type" in out and "type" in s:
676676
tt = s.pop("type")
677+
ot = get_type(out)
678+
if "number" in ot:
679+
ot.append("integer")
677680
out["type"] = [
678-
t for t in get_type(out) if t in tt or t == "integer" and "number" in tt
681+
t for t in ot if t in tt or t == "integer" and "number" in tt
679682
]
680683
out_type = get_type(out)
681684
if not out_type:

tests/test_canonicalise.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ def test_merge_semantics(data, s1, s2):
396396
assume(canonicalish(s1) != FALSEY and canonicalish(s2) != FALSEY)
397397
combined = merged([s1, s2])
398398
assume(combined is not None)
399+
assert combined == merged([s2, s1]) # union is commutative
399400
assume(combined != FALSEY)
400401
_merge_semantics_helper(data, s1, s2, combined)
401402

tests/test_from_schema.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ def test_invalid_schemas_raise(schema):
9797
# Technically valid, but using regex patterns not supported by Python
9898
"draft7/ECMA 262 regex escapes control codes with \\c and lower letter",
9999
"draft7/ECMA 262 regex escapes control codes with \\c and upper letter",
100-
# TODO: this is due to a bug merging {'multipleOf': 2} with {'not': {'maximum': 0}}
101-
"draft7/validate against correct branch, then vs else",
102100
}
103101
FLAKY_SCHEMAS = {
104102
# The following schemas refer to an `$id` rather than a JSON pointer.

0 commit comments

Comments
 (0)