def test_assert_almost_equals_uses_failure_exception(self):
     failer = lambda: assert_almost_equals(2, 4, max_delta=0, failure_exception=TypeError)
     assert_raises(TypeError, failer)
 def test_can_specify_custom_message(self):
     failer = lambda: assert_almost_equals(2, 4, max_delta=0, message='fnord')
     failure = assert_raises(AssertionError, failer)
     self.assertEqual('fnord', exception_message(failure))
 def test_assert_almost_equals_uses_sensible_error_message(self):
     failer = lambda: assert_almost_equals(2, 4, max_delta=1)
     failure = assert_raises(AssertionError, failer)
     self.assertEqual('2 != 4 with maximal difference of 1', exception_message(failure))
 def test_assert_almost_equals_accepts_max_delta(self):
     assert_almost_equals(5, 5, 0)
     assert_almost_equals(6, 5, max_delta=2)
     assert_almost_equals(5, 5.01, max_delta=0.1)
     assert_raises(AssertionError, lambda: assert_almost_equals(5, 5.1, max_delta=0))
 def test_assert_almost_equals_uses_failure_exception(self):
     failer = lambda: assert_almost_equals(
         2, 4, max_delta=0, failure_exception=TypeError)
     assert_raises(TypeError, failer)
 def test_assert_almost_equals_uses_sensible_error_message(self):
     failer = lambda: assert_almost_equals(2, 4, max_delta=1)
     failure = assert_raises(AssertionError, failer)
     self.assertEqual('2 != 4 with maximal difference of 1',
                      exception_message(failure))
 def test_can_specify_custom_message(self):
     failer = lambda: assert_almost_equals(
         2, 4, max_delta=0, message='fnord')
     failure = assert_raises(AssertionError, failer)
     self.assertEqual('fnord', exception_message(failure))
 def test_assert_almost_equals_accepts_max_delta(self):
     assert_almost_equals(5, 5, 0)
     assert_almost_equals(6, 5, max_delta=2)
     assert_almost_equals(5, 5.01, max_delta=0.1)
     assert_raises(AssertionError,
                   lambda: assert_almost_equals(5, 5.1, max_delta=0))