Пример #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'])))
Пример #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
Пример #3
0
 def test_can_specify_exception_to_throw(self):
     assert_raises(TypeError, lambda: assert_contains(1, [], failure_exception=TypeError))
Пример #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))
Пример #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))
Пример #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))
Пример #7
0
 def test_returns_catched_exception(self):
     exception = assert_raises(FooError, self.foo_failer)
     assert isinstance(exception, FooError)
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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)
Пример #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))
Пример #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))
Пример #20
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError,
                   lambda: assert_falsish(True, failure_exception=FooError))
Пример #21
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_falsish(True, failure_exception=FooError))
Пример #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))
Пример #23
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_larger_than(1, 4, failure_exception=FooError))
Пример #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))
Пример #25
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(FooError, lambda: assert_is_empty((1,), failure_exception=FooError))
Пример #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))
Пример #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
Пример #28
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(
         FooError,
         lambda: assert_larger_than(1, 4, failure_exception=FooError))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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)
Пример #34
0
 def test_can_specify_exception_to_throw(self):
     assert_raises(
         TypeError,
         lambda: assert_contains(1, [], failure_exception=TypeError))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #40
0
 def test_can_specify_custom_failure_exception(self):
     assert_raises(
         FooError, lambda: assert_is_empty(
             (1, ), failure_exception=FooError))
Пример #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))
Пример #42
0
 def test_can_detect_raise(self):
     assert_raises(FooError, self.foo_failer)
Пример #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))
Пример #44
0
 def test_returns_catched_exception(self):
     exception = assert_raises(FooError, self.foo_failer)
     assert isinstance(exception, FooError)
Пример #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))
Пример #46
0
 def test_unexpected_exceptions_are_not_catched(self):
     try:
         assert_raises(self.BarError, self.foo_failer)
     except FooError:
         pass
Пример #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'])))
Пример #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))
Пример #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))
Пример #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))
Пример #51
0
 def test_can_detect_raise(self):
     assert_raises(FooError, self.foo_failer)
Пример #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))
Пример #53
0
 def test_unexpected_exceptions_are_not_catched(self):
     try:
         assert_raises(self.BarError, self.foo_failer)
     except FooError:
         pass
Пример #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))
Пример #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))
Пример #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))
Пример #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))
Пример #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']))
Пример #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))
Пример #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']))