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

Method check_division

Lib/test/test_long.py:155–168  ·  view source on GitHub ↗
(self, x, y)

Source from the content-addressed store, hash-verified

153 return answer
154
155 def check_division(self, x, y):
156 eq = self.assertEqual
157 with self.subTest(x=x, y=y):
158 q, r = divmod(x, y)
159 q2, r2 = x//y, x%y
160 pab, pba = x*y, y*x
161 eq(pab, pba, "multiplication does not commute")
162 eq(q, q2, "divmod returns different quotient than /")
163 eq(r, r2, "divmod returns different mod than %")
164 eq(x, q*y + r, "x != q*y + r after divmod")
165 if y > 0:
166 self.assertTrue(0 <= r < y, "bad mod from divmod")
167 else:
168 self.assertTrue(y < r <= 0, "bad mod from divmod")
169
170 def test_division(self):
171 digits = list(range(1, MAXDIGITS+1)) + list(range(KARATSUBA_CUTOFF,

Callers 1

test_divisionMethod · 0.95

Calls 3

eqFunction · 0.85
assertTrueMethod · 0.80
subTestMethod · 0.45

Tested by

no test coverage detected