Skip to content

Commit

Permalink
Suppress Hypothesis warning in test and reuse existing code for case …
Browse files Browse the repository at this point in the history
…strategy
  • Loading branch information
Dmitry Dygalo committed Oct 20, 2019
1 parent b6c4c9a commit 4ea6801
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions test/test_hypothesis.py
@@ -1,12 +1,10 @@
from functools import partial
from unittest.mock import ANY

import pytest
from hypothesis import strategies
from hypothesis_jsonschema import from_schema

from schemathesis import Case, register_string_format
from schemathesis._hypothesis import PARAMETERS, get_examples
from schemathesis._hypothesis import PARAMETERS, get_case_strategy, get_examples
from schemathesis.models import Endpoint


Expand Down Expand Up @@ -49,6 +47,7 @@ def test_warning():
assert not record


@pytest.mark.filterwarnings("ignore:.*method is good for exploring strategies.*")
def test_custom_strategies():
register_string_format("even_4_digits", strategies.from_regex(r"\A[0-9]{4}\Z").filter(lambda x: int(x) % 2 == 0))
endpoint = make_endpoint(
Expand All @@ -61,9 +60,7 @@ def test_custom_strategies():
}
}
)
result = strategies.builds(
partial(Case, path=endpoint.path, method=endpoint.method), query=from_schema(endpoint.query)
).example()
result = get_case_strategy(endpoint).example()
assert len(result.query["id"]) == 4
assert int(result.query["id"]) % 2 == 0

Expand Down

0 comments on commit 4ea6801

Please sign in to comment.