MCPcopy Index your code
hub / github.com/python/cpython / assertNotAlmostEqual

Method assertNotAlmostEqual

Lib/unittest/case.py:981–1014  ·  view source on GitHub ↗

Fail if the two objects are equal as determined by their difference rounded to the given number of decimal places (default 7) and comparing to zero, or by comparing that the difference between the two objects is less than the given delta. Note that decima

(self, first, second, places=None, msg=None,
                             delta=None)

Source from the content-addressed store, hash-verified

979 raise self.failureException(msg)
980
981 def assertNotAlmostEqual(self, first, second, places=None, msg=None,
982 delta=None):
983 """Fail if the two objects are equal as determined by their
984 difference rounded to the given number of decimal places
985 (default 7) and comparing to zero, or by comparing that the
986 difference between the two objects is less than the given delta.
987
988 Note that decimal places (from zero) are usually not the same
989 as significant digits (measured from the most significant digit).
990
991 Objects that are equal automatically fail.
992 """
993 if delta is not None and places is not None:
994 raise TypeError("specify delta or places not both")
995 diff = abs(first - second)
996 if delta is not None:
997 if not (first == second) and diff > delta:
998 return
999 standardMsg = '%s == %s within %s delta (%s difference)' % (
1000 safe_repr(first),
1001 safe_repr(second),
1002 safe_repr(delta),
1003 safe_repr(diff))
1004 else:
1005 if places is None:
1006 places = 7
1007 if not (first == second) and round(diff, places) != 0:
1008 return
1009 standardMsg = '%s == %s within %r places' % (safe_repr(first),
1010 safe_repr(second),
1011 places)
1012
1013 msg = self._formatMessage(msg, standardMsg)
1014 raise self.failureException(msg)
1015
1016 def assertSequenceEqual(self, seq1, seq2, msg=None, seq_type=None):
1017 """An equality assertion for ordered sequences (like lists and tuples).

Callers 3

test_AlmostEqualMethod · 0.80
test_other_unittestMethod · 0.80

Calls 3

_formatMessageMethod · 0.95
absFunction · 0.85
safe_reprFunction · 0.85

Tested by 3

test_AlmostEqualMethod · 0.64
test_other_unittestMethod · 0.64