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)
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)
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)
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)
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)
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 })
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)
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')
def it_should_fail_if_actual_is_none(): with failure(None, 'not to be None'): expect(None).not_to.be.none
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)
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)
def callback(): fail = failure(_.actual, _.message) with fail: raise AssertionError(fail.message)
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)
def it_should_fail_if_actual_has_property(): with failure(_.obj, "not to have property 'bar'"): expect(_.obj).not_to.have.property('bar')
def it_should_fail_if_actual_is_empty(): actual = '' with failure(actual, 'not to be empty'): expect(actual).not_to.be.empty
def it_should_fail_if_actual_has_expected_item(): with failure(_.lst, "not to have 'bar'"): expect(_.lst).not_to.have('bar', 'foo')
def it_should_fail_if_actual_is_false_(): with failure(False, 'not to be False'): expect(False).not_to.be.false
def it_should_fail_if_actual_is_true_(): with failure(True, 'not to be True'): expect(True).not_to.be.true
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)
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)
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')
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)
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)
def it_should_fail_if_actual_does_not_equal_expected_(): with failure(1, 'to be equal 2'): expect(1).to.be.equal(2)
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})
def callback(): with failure(_.actual, _.message): pass
def it_should_fail_if_actual_has_expected_key(): with failure(_.dct, "not to have key 'bar'"): expect(_.dct).not_to.have.key('bar')
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)
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)
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)
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')
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)
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)
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)
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)
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')
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)
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)
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)
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)
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)
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})
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})
def it_should_fail_if_actual_is_not_expected(): with failure(1, 'to be 2'): expect(1).to.be(2)
def it_should_have_failure_message(): message = failure(_.actual, _.message).message expect(message).to.equal('Expected {} {}'.format( repr(_.actual), _.message))
def it_should_pass_if_assertion_error_raised_and_matchs_pattern(): fail = failure(_.actual, _.pattern) with fail: raise AssertionError(failure(_.actual, _.message).message)
def callback(): with failure(_.actual, _.message): raise AssertionError('foo')
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)