def test_can_specify_exception_to_throw(self): assert_raises(TypeError, lambda: assert_contains(1, [], failure_exception=TypeError))
def test_can_specify_custom_message(self): failure = assert_raises(AssertionError, lambda: assert_contains(1, [], message='fnord')) assert_equals('fnord', exception_message(failure))
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_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'))
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_can_specify_exception_to_throw(self): assert_raises( TypeError, lambda: assert_contains(1, [], failure_exception=TypeError))
def test_can_specify_custom_message(self): failure = assert_raises( AssertionError, lambda: assert_contains(1, [], message='fnord')) assert_equals('fnord', exception_message(failure))