Skip to content

Commit

Permalink
Add more tests for uncovered code paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Dygalo authored and Stranger6667 committed Oct 10, 2019
1 parent 8ff77bd commit b55463b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/test_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import sys
import warnings

from hypothesis.errors import NonInteractiveExampleWarning

from schemathesis._compat import handle_warnings


def test_handle_warnings(recwarn):
with handle_warnings():
warnings.warn("Message", NonInteractiveExampleWarning)
assert not recwarn


def test_handle_warnings_old_hypothesis(monkeypatch, recwarn):
# Assume that there is an import error - old hypothesis version
monkeypatch.setitem(sys.modules, "hypothesis.errors", None)
with handle_warnings():
warnings.warn("Message", NonInteractiveExampleWarning)
assert recwarn
15 changes: 15 additions & 0 deletions test/test_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,18 @@ def test_(case):
)
# Then the generated test case should contain it in its `form_data` attribute
testdir.run_and_assert(passed=1)


def test_unknown_data(testdir):
# When parameter is specified for unknown "in"
testdir.make_test(
"""
@schema.parametrize()
@settings(max_examples=1)
def test_(case):
pass
""",
**as_param({"name": "status", "in": "unknown", "required": True, "type": "string"}),
)
# Then the generated test ignores this parameter
testdir.run_and_assert(passed=1)

0 comments on commit b55463b

Please sign in to comment.