Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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
         })
Beispiel #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)
Beispiel #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)
Beispiel #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')
Beispiel #10
0
 def it_should_fail_if_actual_is_none():
     with failure(None, 'not to be None'):
         expect(None).not_to.be.none
Beispiel #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)
Beispiel #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)
Beispiel #13
0
            def callback():
                fail = failure(_.actual, _.message)

                with fail:
                    raise AssertionError(fail.message)
Beispiel #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)
Beispiel #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')
Beispiel #16
0
                def it_should_fail_if_actual_is_empty():
                    actual = ''

                    with failure(actual, 'not to be empty'):
                        expect(actual).not_to.be.empty
Beispiel #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')
Beispiel #18
0
 def it_should_fail_if_actual_is_none():
     with failure(None, 'not to be None'):
         expect(None).not_to.be.none
Beispiel #19
0
 def it_should_fail_if_actual_is_false_():
     with failure(False, 'not to be False'):
         expect(False).not_to.be.false
Beispiel #20
0
 def it_should_fail_if_actual_is_true_():
     with failure(True, 'not to be True'):
         expect(True).not_to.be.true
Beispiel #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')
Beispiel #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)
Beispiel #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)
Beispiel #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')
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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})
Beispiel #29
0
 def callback():
     with failure(_.actual, _.message):
         pass
Beispiel #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')
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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')
Beispiel #35
0
 def it_should_fail_if_actual_is_false_():
     with failure(False, 'not to be False'):
         expect(False).not_to.be.false
Beispiel #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)
Beispiel #37
0
                def it_should_fail_if_actual_is_empty():
                    actual = ''

                    with failure(actual, 'not to be empty'):
                        expect(actual).not_to.be.empty
Beispiel #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)
Beispiel #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')
Beispiel #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)
Beispiel #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')
Beispiel #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)
Beispiel #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')
Beispiel #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)
Beispiel #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')
Beispiel #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)
Beispiel #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')
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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})
Beispiel #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})
Beispiel #53
0
 def it_should_fail_if_actual_is_not_expected():
     with failure(1, 'to be 2'):
         expect(1).to.be(2)
Beispiel #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)
Beispiel #55
0
        def it_should_have_failure_message():
            message = failure(_.actual, _.message).message

            expect(message).to.equal('Expected {} {}'.format(
                repr(_.actual), _.message))
Beispiel #56
0
 def it_should_fail_if_actual_is_not_expected():
     with failure(1, 'to be 2'):
         expect(1).to.be(2)
Beispiel #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)
Beispiel #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)
Beispiel #59
0
 def callback():
     with failure(_.actual, _.message):
         raise AssertionError('foo')
Beispiel #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)