Skip to content

Commit

Permalink
Test strategy inference with only post-conditions (#62)
Browse files Browse the repository at this point in the history
This patch adds a test case which tests that the strategy is correctly
inferred if only the post-conditions are specified.
  • Loading branch information
mristin authored Jul 9, 2021
1 parent df3faeb commit fe6c12a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/strategy_inference/test_strategy_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def some_func(x) -> None: # type: ignore
str(type_error),
)

def test_without_preconditions(self) -> None:
def test_without_contracts(self) -> None:
def some_func(x: int) -> None:
pass

Expand All @@ -59,6 +59,16 @@ def some_func(x: int) -> None:

icontract_hypothesis.test_with_inferred_strategy(some_func)

def test_with_only_preconditions(self) -> None:
@icontract.ensure(lambda result: result > 0)
def some_func(x: int) -> int:
return 1

strategy = icontract_hypothesis.infer_strategy(some_func)
self.assertEqual("fixed_dictionaries({'x': integers()})", str(strategy))

icontract_hypothesis.test_with_inferred_strategy(some_func)

def test_unmatched_pattern(self) -> None:
@icontract.require(lambda x: x > 0 and x > math.sqrt(x))
def some_func(x: float) -> None:
Expand Down

0 comments on commit fe6c12a

Please sign in to comment.