Skip to content

Commit

Permalink
Fix #59, numeric merging bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jul 16, 2020
1 parent 61e0cdf commit fc8c98b
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

#### 0.17.1 - 2020-07-16
- fixed an internal bug where results incorrectly depended on iteration order (#59)

#### 0.17.0 - 2020-07-16
- Adds a `custom_formats` keyword argument to `from_schema()`, so that you can
specify a strategy to generate strings for custom formats like credit card numbers.
Expand Down
2 changes: 1 addition & 1 deletion src/hypothesis_jsonschema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The only public API is `from_schema`; check the docstring for details.
"""

__version__ = "0.17.0"
__version__ = "0.17.1"
__all__ = ["from_schema"]

from ._from_schema import from_schema
5 changes: 4 additions & 1 deletion src/hypothesis_jsonschema/_canonicalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,8 +674,11 @@ def merged(schemas: List[Any]) -> Optional[Schema]:

if "type" in out and "type" in s:
tt = s.pop("type")
ot = get_type(out)
if "number" in ot:
ot.append("integer")
out["type"] = [
t for t in get_type(out) if t in tt or t == "integer" and "number" in tt
t for t in ot if t in tt or t == "integer" and "number" in tt
]
out_type = get_type(out)
if not out_type:
Expand Down
1 change: 1 addition & 0 deletions tests/test_canonicalise.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ def test_merge_semantics(data, s1, s2):
assume(canonicalish(s1) != FALSEY and canonicalish(s2) != FALSEY)
combined = merged([s1, s2])
assume(combined is not None)
assert combined == merged([s2, s1]) # union is commutative
assume(combined != FALSEY)
_merge_semantics_helper(data, s1, s2, combined)

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

0 comments on commit fc8c98b

Please sign in to comment.