Example #1
0
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)
Example #2
0
 def is_good(x):
     assume(x > 5)
     return x % 2 == 0
Example #3
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
Example #4
0
def test_raises_on_unsatisfiable_assumption():
    with pytest.raises(Unsatisfiable):
        falsify(lambda x: assume(False), int)
Example #5
0
 def out_of_order_positive_tuple(x):
     a, b = x
     assume(a > 0 and b > 0)
     assert a >= b
     return True
Example #6
0
 def is_good(x):
     assume('foo' in x)
     assume('bar' in x)
     return x['foo'] < x['bar']
Example #7
0
def test_integer_division_shrinks_positive_integers(n):
    assume(n > 0)
    assert n/2 < n
def test_raises_on_unsatisfiable_assumption():
    with pytest.raises(Unsatisfiable):
        falsify(lambda x: assume(False), int)
Example #9
0
 def out_of_order_positive_tuple(x):
     a,b = x
     assume(a > 0 and b > 0)
     assert a >= b
     return True
Example #10
0
 def is_good(x):
     assume("foo" in x)
     assume("bar" in x) 
     return x["foo"] < x["bar"]
Example #11
0
 def is_good(x):
     assume(x > 5)
     return x % 2 == 0
Example #12
0
def test_can_be_given_keyword_args(x, name):
    assume(x > 0)
    assert len(name) < x
Example #13
0
def test_integer_division_shrinks_positive_integers(n):
    assume(n > 0)
    assert n / 2 < n
Example #14
0
 def is_a_monoculture(xs):
     assume(len(xs) >= 10)
     return len(set(xs)) > 1
Example #15
0
def test_can_be_given_keyword_args(x, name):
    assume(x > 0)
    assert len(name) < x
Example #16
0
 def is_small_given_large(xs):
     assume(len(xs) >= 15)
     return any(x <= 0.8 for x in xs)
Example #17
0
 def is_good(x):
     assume("foo" in x)
     assume("bar" in x)
     return x["foo"] < x["bar"]