def test_rejects_non_empty_values(self):
     assert_raises(AssertionError, lambda: assert_is_empty('fnord'))
     assert_raises(AssertionError, lambda: assert_is_empty(['fnord']))
     assert_raises(AssertionError,
                   lambda: assert_is_empty({'fnord': 'fnord'}))
     assert_raises(AssertionError, lambda: assert_is_empty(('fnord', )))
     assert_raises(AssertionError, lambda: assert_is_empty(set(['fnord'])))
 def test_can_specify_exception_to_raise(self):
     try:
         assert_raises(self.BarError,
                       lambda: None,
                       failure_exception=self.BazError)
     except self.BazError:
         pass
 def test_can_specify_exception_to_throw(self):
     assert_raises(TypeError, lambda: assert_contains(1, [], failure_exception=TypeError))
 def test_uses_sensible_default_error_message(self):
     try:
         assert_raises(self.BarError, lambda: None)
     except AssertionError, exception:
         assert_equals('BarError not raised', exception_message(exception))
 def test_uses_sensible_default_error_message(self):
     failure = assert_raises(AssertionError, lambda: assert_contains(1, []))
     assert_equals('1 not in []', exception_message(failure))
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError, lambda: assert_is_empty((1,)))
     assert_equals('(1,) is not empty', exception_message(exception))
 def test_returns_catched_exception(self):
     exception = assert_raises(FooError, self.foo_failer)
     assert isinstance(exception, FooError)
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError, lambda: assert_true('fnord'))
     assert_equals("True != 'fnord'", exception_message(exception))
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError, lambda: assert_larger_than(1, 4))
     assert_equals('1 is not larger than 4', exception_message(exception))
Beispiel #10
0
 def test_raises_if_value_is_not_smaller(self):
     assert_raises(AssertionError, lambda: assert_true(False))
     assert_raises(AssertionError, lambda: assert_true(None))
     assert_raises(AssertionError, lambda: assert_true(4))
Beispiel #11
0
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError, lambda: assert_true('fnord'))
     assert_equals("True != 'fnord'", exception_message(exception))
Beispiel #12
0
 def test_raises_if_value_is_not_smaller(self):
     assert_raises(AssertionError, lambda: assert_smaller_than(1, 1))
     assert_raises(AssertionError, lambda: assert_smaller_than(4, 1))
     assert_raises(AssertionError, lambda: assert_smaller_than(-4, -5))
Beispiel #13
0
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError,
                               lambda: assert_smaller_than(4, 1))
     assert_equals('4 is not smaller than 1', exception_message(exception))
Beispiel #14
0
 def test_can_specify_custom_message(self):
     assertion = lambda: assert_dict_contains(dict(foo='bar'),
                                              dict(foo='baz'))
     exception = assert_raises(AssertionError, assertion)
     assert_equals("'foo':'bar' not in {'foo': 'baz'}",
                   exception_message(exception))
Beispiel #15
0
 def test_has_sensible_default_error_message_when_values_differ(self):
     assertion = lambda: assert_dict_contains(dict(foo='bar'),
                                              dict(foo='baz'))
     exception = assert_raises(AssertionError, assertion)
     assert_equals("'foo':'bar' not in {'foo': 'baz'}",
                   exception_message(exception))
Beispiel #16
0
 def test_has_sensible_default_error_message(self):
     assertion = lambda: assert_dict_contains(
         dict(definitely_missing='from other dict'), dict())
     exception = assert_raises(AssertionError, assertion)
     assert_equals("'definitely_missing':'from other dict' not in {}",
                   exception_message(exception))
Beispiel #17
0
 def test_throws_if_dict_is_not_contained(self):
     assertion = lambda: assert_dict_contains(dict(not_in='other dict'),
                                              dict())
     assert_raises(AssertionError, assertion)
Beispiel #18
0
 def test_raises_if_value_is_trueish(self):
     assert_raises(AssertionError, lambda: assert_falsish(True))
     assert_raises(AssertionError, lambda: assert_falsish('foo'))
     assert_raises(AssertionError, lambda: assert_falsish(4))
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError, lambda: assert_smaller_than(4, 1))
     assert_equals('4 is not smaller than 1', exception_message(exception))
Beispiel #20
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError,
                   lambda: assert_falsish(True, failure_exception=FooError))
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_falsish(True, failure_exception=FooError))
Beispiel #22
0
 def test_raises_if_value_is_not_smaller(self):
     assert_raises(AssertionError, lambda: assert_larger_than(1, 1))
     assert_raises(AssertionError, lambda: assert_larger_than(1, 4))
     assert_raises(AssertionError, lambda: assert_larger_than(-5, -4))
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_larger_than(1, 4, failure_exception=FooError))
Beispiel #24
0
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError,
                               lambda: assert_larger_than(1, 4))
     assert_equals('1 is not larger than 4', exception_message(exception))
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_is_empty((1,), failure_exception=FooError))
Beispiel #26
0
 def test_can_specify_custom_message(self):
     exception = assert_raises(
         AssertionError, lambda: assert_larger_than(1, 4, message='fnord'))
     assert_equals('fnord', exception_message(exception))
 def test_can_specify_exception_to_raise(self):
     try:
         assert_raises(self.BarError, lambda: None, failure_exception=self.BazError)
     except self.BazError:
         pass
Beispiel #28
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(
         FooError,
         lambda: assert_larger_than(1, 4, failure_exception=FooError))
 def test_can_specify_custom_message(self):
     failure = assert_raises(AssertionError, lambda: assert_equals(1, 2, message='fnord'))
     assert_equals('fnord', exception_message(failure))
 def test_has_sensible_default_error_message(self):
     assertion = lambda: assert_dict_contains(dict(definitely_missing='from other dict'), dict())
     exception = assert_raises(AssertionError, assertion)
     assert_equals("'definitely_missing':'from other dict' not in {}", exception_message(exception))
 def test_uses_sensible_default_error_message(self):
     failure = assert_raises(AssertionError, lambda: assert_contains(1, []))
     assert_equals('1 not in []', exception_message(failure))
 def test_can_specify_custom_message(self):
     assertion = lambda: assert_dict_contains(dict(foo='bar'), dict(foo='baz'))
     exception = assert_raises(AssertionError, assertion)
     assert_equals("'foo':'bar' not in {'foo': 'baz'}", exception_message(exception))
 def test_throws_if_dict_is_not_contained(self):
     assertion = lambda: assert_dict_contains(dict(not_in='other dict'), dict())
     assert_raises(AssertionError, assertion)
Beispiel #34
0
 def test_can_specify_exception_to_throw(self):
     assert_raises(
         TypeError,
         lambda: assert_contains(1, [], failure_exception=TypeError))
 def test_has_sensible_default_error_message_when_values_differ(self):
     assertion = lambda: assert_dict_contains(dict(foo='bar'), dict(foo='baz'))
     exception = assert_raises(AssertionError, assertion)
     assert_equals("'foo':'bar' not in {'foo': 'baz'}", exception_message(exception))
Beispiel #36
0
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError, lambda: assert_is_empty(
         (1, )))
     assert_equals('(1,) is not empty', exception_message(exception))
 def test_raises_if_value_is_not_smaller(self):
     assert_raises(AssertionError, lambda: assert_smaller_than(1, 1))
     assert_raises(AssertionError, lambda: assert_smaller_than(4, 1))
     assert_raises(AssertionError, lambda: assert_smaller_than(-4, -5))
Beispiel #38
0
 def test_can_specify_custom_message(self):
     exception = assert_raises(
         AssertionError, lambda: assert_is_empty((1, ), message='fnord'))
     assert_equals('fnord', exception_message(exception))
 def test_raises_if_value_is_not_smaller(self):
     assert_raises(AssertionError, lambda: assert_true(False))
     assert_raises(AssertionError, lambda: assert_true(None))
     assert_raises(AssertionError, lambda: assert_true(4))
Beispiel #40
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(
         FooError, lambda: assert_is_empty(
             (1, ), failure_exception=FooError))
 def test_raises_if_value_is_trueish(self):
     assert_raises(AssertionError, lambda: assert_falsish(True))
     assert_raises(AssertionError, lambda: assert_falsish('foo'))
     assert_raises(AssertionError, lambda: assert_falsish(4))
Beispiel #42
0
 def test_can_detect_raise(self):
     assert_raises(FooError, self.foo_failer)
 def test_raises_if_value_is_not_smaller(self):
     assert_raises(AssertionError, lambda: assert_larger_than(1, 1))
     assert_raises(AssertionError, lambda: assert_larger_than(1, 4))
     assert_raises(AssertionError, lambda: assert_larger_than(-5, -4))
Beispiel #44
0
 def test_returns_catched_exception(self):
     exception = assert_raises(FooError, self.foo_failer)
     assert isinstance(exception, FooError)
 def test_can_specify_custom_message(self):
     exception = assert_raises(AssertionError, lambda: assert_larger_than(1, 4, message='fnord'))
     assert_equals('fnord', exception_message(exception))
Beispiel #46
0
 def test_unexpected_exceptions_are_not_catched(self):
     try:
         assert_raises(self.BarError, self.foo_failer)
     except FooError:
         pass
 def test_rejects_non_empty_values(self):
     assert_raises(AssertionError, lambda: assert_is_empty('fnord'))
     assert_raises(AssertionError, lambda: assert_is_empty(['fnord']))
     assert_raises(AssertionError, lambda: assert_is_empty({'fnord':'fnord'}))
     assert_raises(AssertionError, lambda: assert_is_empty(('fnord',)))
     assert_raises(AssertionError, lambda: assert_is_empty(set(['fnord'])))
Beispiel #48
0
 def test_can_specify_custom_message(self):
     try:
         assert_raises(self.BarError, lambda: None, message='fnord')
     except AssertionError, exception:
         assert_equals('fnord', exception_message(exception))
 def test_can_specify_custom_message(self):
     exception = assert_raises(AssertionError, lambda: assert_is_empty((1,), message='fnord'))
     assert_equals('fnord', exception_message(exception))
Beispiel #50
0
 def test_uses_sensible_default_error_message(self):
     try:
         assert_raises(self.BarError, lambda: None)
     except AssertionError, exception:
         assert_equals('BarError not raised', exception_message(exception))
 def test_can_detect_raise(self):
     assert_raises(FooError, self.foo_failer)
Beispiel #52
0
 def test_raises_on_different_values(self):
     assert_raises(AssertionError, lambda: assert_equals(1, 2))
     assert_raises(AssertionError, lambda: assert_equals(None, 2))
 def test_unexpected_exceptions_are_not_catched(self):
     try:
         assert_raises(self.BarError, self.foo_failer)
     except FooError:
         pass
Beispiel #54
0
 def test_can_specify_custom_message(self):
     failure = assert_raises(AssertionError,
                             lambda: assert_equals(1, 2, message='fnord'))
     assert_equals('fnord', exception_message(failure))
 def test_can_specify_custom_message(self):
     try:
         assert_raises(self.BarError, lambda: None, message='fnord')
     except AssertionError, exception:
         assert_equals('fnord', exception_message(exception))
Beispiel #56
0
 def test_uses_sensible_default_error_message(self):
     failure = assert_raises(AssertionError, lambda: assert_equals(1, 2))
     assert_equals('1 != 2', exception_message(failure))
 def test_raises_on_different_values(self):
     assert_raises(AssertionError, lambda: assert_equals(1, 2))
     assert_raises(AssertionError, lambda: assert_equals(None, 2))
 def test_raises_if_item_is_not_in_iterable(self):
     assert_raises(AssertionError, lambda: assert_contains('fnord', []))
     assert_raises(AssertionError, lambda: assert_contains('fnord', ['foo']))
 def test_uses_sensible_default_error_message(self):
     failure = assert_raises(AssertionError, lambda: assert_equals(1, 2))
     assert_equals('1 != 2', exception_message(failure))
Beispiel #60
0
 def test_raises_if_item_is_not_in_iterable(self):
     assert_raises(AssertionError, lambda: assert_contains('fnord', []))
     assert_raises(AssertionError,
                   lambda: assert_contains('fnord', ['foo']))