MCPcopy Index your code
hub / github.com/RustPython/RustPython / assertNotAlmostEqual

Method assertNotAlmostEqual

Lib/unittest/case.py:986–1019  ·  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

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

Callers 3

test_AlmostEqualMethod · 0.80
test_other_unittestMethod · 0.80

Calls 4

_formatMessageMethod · 0.95
safe_reprFunction · 0.85
roundFunction · 0.85
absFunction · 0.50

Tested by 3

test_AlmostEqualMethod · 0.64
test_other_unittestMethod · 0.64