Ejemplo n.º 1
0
                def it_should_fail_if_actual_is_not_an_instance_of_the_expected_class(
                ):
                    class Bar(object):
                        pass

                    with failure(_.obj, 'to be a Bar instance'):
                        expect(_.obj).to.be.a(Bar)
Ejemplo n.º 2
0
                def it_should_fail_if_actual_is_not_an_instance_of_the_expected_class_(
                ):
                    class Object(object):
                        pass

                    with failure(_.obj, 'to be an Object instance'):
                        expect(_.obj).to.be.an(Object)
Ejemplo n.º 3
0
            def it_should_fail_if_actual_does_not_raise_expected_exception():
                def callback():
                    raise KeyError()

                with failure(callback,
                             'to raise AttributeError but KeyError raised'):
                    expect(callback).to.raise_error(AttributeError)
Ejemplo n.º 4
0
 def it_should_fail_if_actual_has_property_in_kwargs_but_not_in_args(
 ):
     with failure(
             _.obj,
             "not to have property 'bar' with value 0 but was 0"
     ):
         expect(_.obj).not_to.have.properties('foo', bar=0)
Ejemplo n.º 5
0
            def it_should_fail_if_actual_raises_expected_exception():
                def callback():
                    raise AttributeError()

                with failure(
                        callback,
                        'not to raise AttributeError but AttributeError raised'
                ):
                    expect(callback).not_to.raise_error(AttributeError)
Ejemplo n.º 6
0
 def it_should_fail_if_actual_has_property_in_dict_with_value():
     with failure(
             _.obj,
             "not to have property 'bar' with value 0 but was 0"
     ):
         expect(_.obj).not_to.have.properties({
             'bar': 0,
             'foo': 1
         })
Ejemplo n.º 7
0
            def it_should_fail_if_actual_raises_expected_exception_with_message():
                message = 'Foo error'
                failure_message = 'not to raise AttributeError with message {} but message was {}'.format(
                    repr(message), repr(message))

                def callback():
                    raise AttributeError(message)

                with failure(callback, failure_message):
                    expect(callback).not_to.raise_error(AttributeError, message)
Ejemplo n.º 8
0
            def it_should_fail_if_actual_raises_expected_exception_with_message():
                message = 'Foo error'
                failure_message = 'not to raise AttributeError with message {} but message was {}'.format(
                    repr(message), repr(message))

                def callback():
                    raise AttributeError(message)

                with failure(callback, failure_message):
                    expect(callback).not_to.raise_error(AttributeError, message)
Ejemplo n.º 9
0
            def it_should_fail_if_actual_raises_expected_exception_with_different_message(
            ):
                def callback():
                    raise AttributeError('bar')

                with failure(
                        callback,
                        "to raise AttributeError with message 'foo' but message was 'bar'"
                ):
                    expect(callback).to.raise_error(AttributeError, 'foo')
Ejemplo n.º 10
0
 def it_should_fail_if_actual_is_none():
     with failure(None, 'not to be None'):
         expect(None).not_to.be.none
Ejemplo n.º 11
0
 def it_should_fail_if_actual_is_greater_than_expected_():
     with failure(5, 'not to be greater or equal to 4'):
         expect(5).not_to.be.greater_or_equal_to(4)
Ejemplo n.º 12
0
 def it_should_fail_if_actual_is_less_than_expected():
     with failure(1, 'not to be less than 4'):
         expect(1).not_to.be.less_than(4)
Ejemplo n.º 13
0
            def callback():
                fail = failure(_.actual, _.message)

                with fail:
                    raise AssertionError(fail.message)
Ejemplo n.º 14
0
                def it_should_fail_if_actual_has_the_expected_length():
                    actual = 'foo'

                    with failure(actual, 'not to have length 3 but was 3'):
                        expect(actual).not_to.have.length(3)
Ejemplo n.º 15
0
 def it_should_fail_if_actual_has_property():
     with failure(_.obj, "not to have property 'bar'"):
         expect(_.obj).not_to.have.property('bar')
Ejemplo n.º 16
0
                def it_should_fail_if_actual_is_empty():
                    actual = ''

                    with failure(actual, 'not to be empty'):
                        expect(actual).not_to.be.empty
Ejemplo n.º 17
0
 def it_should_fail_if_actual_has_expected_item():
     with failure(_.lst, "not to have 'bar'"):
         expect(_.lst).not_to.have('bar', 'foo')
Ejemplo n.º 18
0
 def it_should_fail_if_actual_is_none():
     with failure(None, 'not to be None'):
         expect(None).not_to.be.none
Ejemplo n.º 19
0
 def it_should_fail_if_actual_is_false_():
     with failure(False, 'not to be False'):
         expect(False).not_to.be.false
Ejemplo n.º 20
0
 def it_should_fail_if_actual_is_true_():
     with failure(True, 'not to be True'):
         expect(True).not_to.be.true
Ejemplo n.º 21
0
 def it_should_fail_if_actual_has_expected_item():
     with failure(_.lst, "not to have 'bar'"):
         expect(_.lst).not_to.have('bar', 'foo')
Ejemplo n.º 22
0
 def it_should_fail_if_actual_has_property_with_value():
     with failure(_.obj, "not to have property 'bar' with value 0 but was 0"):
         expect(_.obj).not_to.have.property('bar', 0)
Ejemplo n.º 23
0
 def it_should_fail_if_actual_has_property_with_value():
     with failure(
             _.obj,
             "not to have property 'bar' with value 0 but was 0"
     ):
         expect(_.obj).not_to.have.property('bar', 0)
Ejemplo n.º 24
0
 def it_should_fail_if_actual_has_property_in_args():
     with failure(_.obj, "not to have property 'bar'"):
         expect(_.obj).not_to.have.properties('foo', 'bar')
Ejemplo n.º 25
0
 def it_should_fail_if_actual_is_within_expected_range():
     with failure(5, 'not to be within 4, 7'):
         expect(5).not_to.be.within(4, 7)
Ejemplo n.º 26
0
 def it_should_fail_if_actual_has_property_in_kwargs_but_not_in_args():
     with failure(_.obj, "not to have property 'bar' with value 0 but was 0"):
         expect(_.obj).not_to.have.properties('foo', bar=0)
Ejemplo n.º 27
0
 def it_should_fail_if_actual_does_not_equal_expected_():
     with failure(1, 'to be equal 2'):
         expect(1).to.be.equal(2)
Ejemplo n.º 28
0
 def it_should_fail_if_actual_has_property_in_dict_with_value():
     with failure(_.obj, "not to have property 'bar' with value 0 but was 0"):
         expect(_.obj).not_to.have.properties({'bar': 0, 'foo': 1})
Ejemplo n.º 29
0
 def callback():
     with failure(_.actual, _.message):
         pass
Ejemplo n.º 30
0
 def it_should_fail_if_actual_has_expected_key():
     with failure(_.dct, "not to have key 'bar'"):
         expect(_.dct).not_to.have.key('bar')
Ejemplo n.º 31
0
 def it_should_fail_if_actual_is_less_than_expected_():
     with failure(1, 'not to be less or equal to 4'):
         expect(1).not_to.be.less_or_equal_to(4)
Ejemplo n.º 32
0
 def it_should_fail_if_actual_has_expected_key_with_value():
     with failure(_.dct, "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.key('bar', 0)
Ejemplo n.º 33
0
 def it_should_fail_if_actual_is_equal_to_expected():
     with failure(5, 'not to be greater or equal to 5'):
         expect(5).not_to.be.greater_or_equal_to(5)
Ejemplo n.º 34
0
            def it_should_fail_if_actual_raises_expected_exception_with_different_message():
                def callback():
                    raise AttributeError('bar')

                with failure(callback, "to raise AttributeError with message 'foo' but message was 'bar'"):
                    expect(callback).to.raise_error(AttributeError, 'foo')
Ejemplo n.º 35
0
 def it_should_fail_if_actual_is_false_():
     with failure(False, 'not to be False'):
         expect(False).not_to.be.false
Ejemplo n.º 36
0
 def it_should_fail_if_actual_is_equal_to_expected_():
     with failure(5, 'not to be less or equal to 5'):
         expect(5).not_to.be.less_or_equal_to(5)
Ejemplo n.º 37
0
                def it_should_fail_if_actual_is_empty():
                    actual = ''

                    with failure(actual, 'not to be empty'):
                        expect(actual).not_to.be.empty
Ejemplo n.º 38
0
 def it_should_fail_if_actual_has_expected_key_with_value():
     with failure(
             _.dct,
             "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.key('bar', 0)
Ejemplo n.º 39
0
 def it_should_fail_if_actual_has_property():
     with failure(_.obj, "not to have property 'bar'"):
         expect(_.obj).not_to.have.property('bar')
Ejemplo n.º 40
0
 def it_should_fail_if_actual_has_key_in_kwargs_with_value():
     with failure(
             _.dct,
             "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.keys(baz=0, bar=0)
Ejemplo n.º 41
0
 def it_should_fail_if_actual_has_property_in_args():
     with failure(_.obj, "not to have property 'bar'"):
         expect(_.obj).not_to.have.properties('foo', 'bar')
Ejemplo n.º 42
0
 def it_should_fail_if_actual_has_key_in_kwargs_but_not_in_args(
 ):
     with failure(
             _.dct,
             "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.keys('foo', bar=0)
Ejemplo n.º 43
0
 def it_should_fail_if_actual_has_key_in_args():
     with failure(_.dct, "not to have key 'bar'"):
         expect(_.dct).not_to.have.keys('foo', 'bar')
Ejemplo n.º 44
0
            def it_should_fail_if_actual_does_not_raise_exception():
                callback = lambda: None

                with failure(callback, 'to raise AttributeError but None raised'):
                    expect(callback).to.raise_error(AttributeError)
Ejemplo n.º 45
0
 def it_should_fail_if_actual_has_expected_key():
     with failure(_.dct, "not to have key 'bar'"):
         expect(_.dct).not_to.have.key('bar')
Ejemplo n.º 46
0
 def it_should_fail_if_actual_has_key_in_kwargs_with_value():
     with failure(_.dct, "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.keys(baz=0, bar=0)
Ejemplo n.º 47
0
 def it_should_fail_if_actual_has_key_in_args():
     with failure(_.dct, "not to have key 'bar'"):
         expect(_.dct).not_to.have.keys('foo', 'bar')
Ejemplo n.º 48
0
 def it_should_fail_if_actual_has_key_in_args_but_not_in_kwargs():
     with failure(_.dct, "not to have key 'bar'"):
         expect(_.dct).not_to.have.keys('bar', baz=0)
Ejemplo n.º 49
0
 def it_should_fail_if_actual_has_key_in_args_but_not_in_kwargs(
 ):
     with failure(_.dct, "not to have key 'bar'"):
         expect(_.dct).not_to.have.keys('bar', baz=0)
Ejemplo n.º 50
0
 def it_should_fail_if_actual_has_key_in_kwargs_but_not_in_args():
     with failure(_.dct, "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.keys('foo', bar=0)
Ejemplo n.º 51
0
 def it_should_fail_if_actual_has_key_in_dict_with_value():
     with failure(
             _.dct,
             "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.keys({'bar': 0, 'foo': 1})
Ejemplo n.º 52
0
 def it_should_fail_if_actual_has_key_in_dict_with_value():
     with failure(_.dct, "not to have key 'bar' with value 0 but was 0"):
         expect(_.dct).not_to.have.keys({'bar': 0, 'foo': 1})
Ejemplo n.º 53
0
 def it_should_fail_if_actual_is_not_expected():
     with failure(1, 'to be 2'):
         expect(1).to.be(2)
Ejemplo n.º 54
0
                def it_should_fail_if_actual_has_the_expected_length():
                    actual = 'foo'

                    with failure(actual, 'not to have length 3 but was 3'):
                        expect(actual).not_to.have.length(3)
Ejemplo n.º 55
0
        def it_should_have_failure_message():
            message = failure(_.actual, _.message).message

            expect(message).to.equal('Expected {} {}'.format(
                repr(_.actual), _.message))
Ejemplo n.º 56
0
 def it_should_fail_if_actual_is_not_expected():
     with failure(1, 'to be 2'):
         expect(1).to.be(2)
Ejemplo n.º 57
0
        def it_should_pass_if_assertion_error_raised_and_matchs_pattern():
            fail = failure(_.actual, _.pattern)

            with fail:
                raise AssertionError(failure(_.actual, _.message).message)
Ejemplo n.º 58
0
 def it_should_fail_if_actual_does_not_equal_expected_():
     with failure(1, 'to be equal 2'):
         expect(1).to.be.equal(2)
Ejemplo n.º 59
0
 def callback():
     with failure(_.actual, _.message):
         raise AssertionError('foo')
Ejemplo n.º 60
0
                def it_should_fail_if_actual_is_not_an_instance_of_the_expected_class():
                    class Bar(object):
                        pass

                    with failure(_.obj, 'to be a Bar instance'):
                        expect(_.obj).to.be.a(Bar)