def test_can_falsify_complex_numbers(): falsify(lambda x: assume(abs(x) <= 1000) and x == (x**2)**0.5, complex) with pytest.raises(Unfalsifiable): falsify( lambda x, y: actually_equal((x * y).conjugate(), x.conjugate() * y.conjugate()), complex, complex)
def is_good(x): assume(x > 5) return x % 2 == 0
def just_being_awkward(xs): assume(len(xs) >= 10) all_value_counts[0] += 1 assume(all(x >= 0 for x in xs)) good_value_counts[0] += 1 return True
def test_raises_on_unsatisfiable_assumption(): with pytest.raises(Unsatisfiable): falsify(lambda x: assume(False), int)
def out_of_order_positive_tuple(x): a, b = x assume(a > 0 and b > 0) assert a >= b return True
def is_good(x): assume('foo' in x) assume('bar' in x) return x['foo'] < x['bar']
def test_integer_division_shrinks_positive_integers(n): assume(n > 0) assert n/2 < n
def out_of_order_positive_tuple(x): a,b = x assume(a > 0 and b > 0) assert a >= b return True
def is_good(x): assume("foo" in x) assume("bar" in x) return x["foo"] < x["bar"]
def test_can_be_given_keyword_args(x, name): assume(x > 0) assert len(name) < x
def test_integer_division_shrinks_positive_integers(n): assume(n > 0) assert n / 2 < n
def is_a_monoculture(xs): assume(len(xs) >= 10) return len(set(xs)) > 1
def is_small_given_large(xs): assume(len(xs) >= 15) return any(x <= 0.8 for x in xs)