Exemplo n.º 1
0
 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'])))
Exemplo n.º 2
0
 def test_can_specify_exception_to_raise(self):
     try:
         assert_raises(self.BarError,
                       lambda: None,
                       failure_exception=self.BazError)
     except self.BazError:
         pass
Exemplo n.º 3
0
 def test_can_specify_exception_to_throw(self):
     assert_raises(TypeError, lambda: assert_contains(1, [], failure_exception=TypeError))
Exemplo n.º 4
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))
Exemplo n.º 5
0
 def test_uses_sensible_default_error_message(self):
     failure = assert_raises(AssertionError, lambda: assert_contains(1, []))
     assert_equals('1 not in []', exception_message(failure))
Exemplo n.º 6
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))
Exemplo n.º 7
0
 def test_returns_catched_exception(self):
     exception = assert_raises(FooError, self.foo_failer)
     assert isinstance(exception, FooError)
Exemplo n.º 8
0
 def test_has_sensible_default_error_message(self):
     exception = assert_raises(AssertionError, lambda: assert_true('fnord'))
     assert_equals("True != 'fnord'", exception_message(exception))
Exemplo n.º 9
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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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))
Exemplo n.º 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)
Exemplo n.º 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))
Exemplo n.º 19
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))
Exemplo n.º 20
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError,
                   lambda: assert_falsish(True, failure_exception=FooError))
Exemplo n.º 21
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_falsish(True, failure_exception=FooError))
Exemplo n.º 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))
Exemplo n.º 23
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_larger_than(1, 4, failure_exception=FooError))
Exemplo n.º 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))
Exemplo n.º 25
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_is_empty((1,), failure_exception=FooError))
Exemplo n.º 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))
Exemplo n.º 27
0
 def test_can_specify_exception_to_raise(self):
     try:
         assert_raises(self.BarError, lambda: None, failure_exception=self.BazError)
     except self.BazError:
         pass
Exemplo n.º 28
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(
         FooError,
         lambda: assert_larger_than(1, 4, failure_exception=FooError))
Exemplo n.º 29
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))
Exemplo n.º 30
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))
Exemplo n.º 31
0
 def test_uses_sensible_default_error_message(self):
     failure = assert_raises(AssertionError, lambda: assert_contains(1, []))
     assert_equals('1 not in []', exception_message(failure))
Exemplo n.º 32
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))
Exemplo n.º 33
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)
Exemplo n.º 34
0
 def test_can_specify_exception_to_throw(self):
     assert_raises(
         TypeError,
         lambda: assert_contains(1, [], failure_exception=TypeError))
Exemplo n.º 35
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))
Exemplo n.º 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))
Exemplo n.º 37
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))
Exemplo n.º 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))
Exemplo n.º 39
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))
Exemplo n.º 40
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(
         FooError, lambda: assert_is_empty(
             (1, ), failure_exception=FooError))
Exemplo n.º 41
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))
Exemplo n.º 42
0
 def test_can_detect_raise(self):
     assert_raises(FooError, self.foo_failer)
Exemplo n.º 43
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))
Exemplo n.º 44
0
 def test_returns_catched_exception(self):
     exception = assert_raises(FooError, self.foo_failer)
     assert isinstance(exception, FooError)
Exemplo n.º 45
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))
Exemplo n.º 46
0
 def test_unexpected_exceptions_are_not_catched(self):
     try:
         assert_raises(self.BarError, self.foo_failer)
     except FooError:
         pass
Exemplo n.º 47
0
 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'])))
Exemplo n.º 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))
Exemplo n.º 49
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))
Exemplo n.º 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))
Exemplo n.º 51
0
 def test_can_detect_raise(self):
     assert_raises(FooError, self.foo_failer)
Exemplo n.º 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))
Exemplo n.º 53
0
 def test_unexpected_exceptions_are_not_catched(self):
     try:
         assert_raises(self.BarError, self.foo_failer)
     except FooError:
         pass
Exemplo n.º 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))
Exemplo n.º 55
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))
Exemplo n.º 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))
Exemplo n.º 57
0
 def test_raises_on_different_values(self):
     assert_raises(AssertionError, lambda: assert_equals(1, 2))
     assert_raises(AssertionError, lambda: assert_equals(None, 2))
Exemplo n.º 58
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']))
Exemplo n.º 59
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))
Exemplo n.º 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']))