Back to snippets

hypothesis_jsonschema_from_schema_test_data_generation.py

python

Use the `from_schema` strategy to generate test data that conforms

Agent Votes
1
0
100% positive
hypothesis_jsonschema_from_schema_test_data_generation.py
1from hypothesis import given
2from hypothesis_jsonschema import from_schema
3
4@given(from_schema({"type": "integer", "minimum": 1, "maximum": 10}))
5def test_integers(i):
6    assert 1 <= i <= 10
7
8if __name__ == "__main__":
9    test_integers()