Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(276294)

Side by Side Diff: Lib/test/test_binop.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_augassign.py ('k') | Lib/test/test_bisect.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """Tests for binary operators on subtypes of built-in types.""" 1 """Tests for binary operators on subtypes of built-in types."""
2 2
3 import unittest 3 import unittest
4 from test import support 4 from test import support
5 from operator import eq, ne, lt, gt, le, ge 5 from operator import eq, ne, lt, gt, le, ge
6 6
7 def gcd(a, b): 7 def gcd(a, b):
8 """Greatest common divisor using Euclid's algorithm.""" 8 """Greatest common divisor using Euclid's algorithm."""
9 while a: 9 while a:
10 a, b = b%a, a 10 a, b = b%a, a
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 def test_gcd(self): 204 def test_gcd(self):
205 self.assertEqual(gcd(10, 12), 2) 205 self.assertEqual(gcd(10, 12), 2)
206 self.assertEqual(gcd(10, 15), 5) 206 self.assertEqual(gcd(10, 15), 5)
207 self.assertEqual(gcd(10, 11), 1) 207 self.assertEqual(gcd(10, 11), 1)
208 self.assertEqual(gcd(100, 15), 5) 208 self.assertEqual(gcd(100, 15), 5)
209 self.assertEqual(gcd(-10, 2), -2) 209 self.assertEqual(gcd(-10, 2), -2)
210 self.assertEqual(gcd(10, -2), 2) 210 self.assertEqual(gcd(10, -2), 2)
211 self.assertEqual(gcd(-10, -2), -2) 211 self.assertEqual(gcd(-10, -2), -2)
212 for i in range(1, 20): 212 for i in range(1, 20):
213 for j in range(1, 20): 213 for j in range(1, 20):
214 self.assertTrue(gcd(i, j) > 0) 214 self.assertGreater(gcd(i, j), 0)
215 self.assertTrue(gcd(-i, j) < 0) 215 self.assertLess(gcd(-i, j), 0)
216 self.assertTrue(gcd(i, -j) > 0) 216 self.assertGreater(gcd(i, -j), 0)
217 self.assertTrue(gcd(-i, -j) < 0) 217 self.assertLess(gcd(-i, -j), 0)
218 218
219 def test_constructor(self): 219 def test_constructor(self):
220 a = Rat(10, 15) 220 a = Rat(10, 15)
221 self.assertEqual(a.num, 2) 221 self.assertEqual(a.num, 2)
222 self.assertEqual(a.den, 3) 222 self.assertEqual(a.den, 3)
223 a = Rat(10, -15) 223 a = Rat(10, -15)
224 self.assertEqual(a.num, -2) 224 self.assertEqual(a.num, -2)
225 self.assertEqual(a.den, 3) 225 self.assertEqual(a.den, 3)
226 a = Rat(-10, 15) 226 a = Rat(-10, 15)
227 self.assertEqual(a.num, -2) 227 self.assertEqual(a.num, -2)
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 self.assertEqual(op_sequence(le, A, B), ['A.__le__', 'B.__ge__']) 371 self.assertEqual(op_sequence(le, A, B), ['A.__le__', 'B.__ge__'])
372 self.assertEqual(op_sequence(le, B, A), ['B.__le__', 'A.__ge__']) 372 self.assertEqual(op_sequence(le, B, A), ['B.__le__', 'A.__ge__'])
373 self.assertEqual(op_sequence(le, B, C), ['C.__ge__', 'B.__le__']) 373 self.assertEqual(op_sequence(le, B, C), ['C.__ge__', 'B.__le__'])
374 self.assertEqual(op_sequence(le, C, B), ['C.__le__', 'B.__ge__']) 374 self.assertEqual(op_sequence(le, C, B), ['C.__le__', 'B.__ge__'])
375 375
376 def test_main(): 376 def test_main():
377 support.run_unittest(RatTestCase, OperationOrderTests) 377 support.run_unittest(RatTestCase, OperationOrderTests)
378 378
379 if __name__ == "__main__": 379 if __name__ == "__main__":
380 test_main() 380 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_augassign.py ('k') | Lib/test/test_bisect.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+