def test_assuming_kwargs(): @forall(i=integers(high=10), s=strings) @assuming(i=greater_than(11), s=instance_of(basestring)) def example(i): assert i > 11 #would fail if run.... assert isinstance(s, int) #would also fail... example()
def test_assumption_failure_disable_test_function(): @assuming(instance_of(int)) def example(i): raise MyException('we did not intend to run this code!!!') try: example(123) raise Exception('expected MyException to be thrown but was not...') except MyException: pass try: example('this should raise an assumption failure exception') except qc.AssumptionFalsified: pass
def check_generator_in_use(i): assert_that(i, instance_of(int))
def test_pairs(p): assert_that(len(p), 2) (l,r) = p assert_that(l, instance_of(int)) assert_that(r, instance_of(str))
def test_type_generation_honors_bases(t): assert_that(t.__bases__, has_item(BaseX)) assert_that(t(), instance_of(BaseX))