コード例 #1
0
 def test_can_specify_exception_to_throw(self):
     assert_raises(TypeError, lambda: assert_contains(1, [], failure_exception=TypeError))
コード例 #2
0
 def test_can_specify_custom_message(self):
     failure = assert_raises(AssertionError, lambda: assert_contains(1, [], message='fnord'))
     assert_equals('fnord', exception_message(failure))
コード例 #3
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))
コード例 #4
0
 def test_can_detect_values_in_iterables(self):
     assert_contains('fnord', ['fnord', 'foo'])
     assert_contains('fnord', ('fnord', 'foo'))
     assert_contains('fnord', set(('fnord', 'foo')))
     assert_contains('fnord', dict(fnord='foo'))
コード例 #5
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']))
コード例 #6
0
 def test_can_specify_exception_to_throw(self):
     assert_raises(
         TypeError,
         lambda: assert_contains(1, [], failure_exception=TypeError))
コード例 #7
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))
コード例 #8
0
 def test_can_specify_custom_message(self):
     failure = assert_raises(
         AssertionError, lambda: assert_contains(1, [], message='fnord'))
     assert_equals('fnord', exception_message(failure))
コード例 #9
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']))
コード例 #10
0
 def test_can_detect_values_in_iterables(self):
     assert_contains('fnord', ['fnord', 'foo'])
     assert_contains('fnord', ('fnord', 'foo'))
     assert_contains('fnord', set(('fnord', 'foo')))
     assert_contains('fnord', dict(fnord='foo'))