Exemplo n.º 1
0
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()
Exemplo n.º 2
0
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
Exemplo n.º 3
0
def check_generator_in_use(i):
    assert_that(i, instance_of(int))
Exemplo n.º 4
0
def test_pairs(p):
    assert_that(len(p), 2)
    (l,r) = p
    assert_that(l, instance_of(int))
    assert_that(r, instance_of(str))
Exemplo n.º 5
0
def test_type_generation_honors_bases(t):
    assert_that(t.__bases__,    has_item(BaseX))
    assert_that(t(),            instance_of(BaseX))