Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_known_content_type(args):
app, kwargs = args
# When endpoint returns a response with a proper content type
# And "content_type_conformance" is specified
results = execute(**kwargs, checks=(content_type_conformance,), hypothesis_options={"max_examples": 1})
# Then there should be no a failures
assert not results.has_failures
def test_content_type_conformance_valid(response, case):
assert content_type_conformance(response, case) is None
def test_content_type_conformance_invalid(response, case):
message = (
f"^Received a response with '{response.headers['Content-Type']}' Content-Type, "
"but it is not declared in the schema.\n\nDefined content types: application/json$"
)
with pytest.raises(AssertionError, match=message):
content_type_conformance(response, case)