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

## Side by Side Diff: Lib/test/test_augassign.py

Issue 16510: Using appropriate checks in tests
Patch Set: Created 6 years, 4 months ago
 Left: Base Patch Set 1: None Patch Set 2: None Patch Set 3: None Patch Set 4: None Patch Set 5: None Right: Patch Set 1: None Patch Set 2: None Patch Set 3: None Patch Set 4: None Patch Set 5: None
« no previous file with comments | « Lib/test/test_asyncore.py ('k') | Lib/test/test_bigmem.py » ('j') | no next file with comments »
OLDNEW
1 # Augmented assignment test. 1 # Augmented assignment test.
2 2
3 from test.support import run_unittest 3 from test.support import run_unittest
4 import unittest 4 import unittest
5 5
6 6
7 class AugAssignTest(unittest.TestCase): 7 class AugAssignTest(unittest.TestCase):
8 def testBasic(self): 8 def testBasic(self):
9 x = 2 9 x = 2
10 x += 1 10 x += 1
(...skipping 45 matching lines...)
56 x *= 2 56 x *= 2
57 57
58 self.assertEqual(x, [1, 2, 3, 4, 1, 2, 3, 4]) 58 self.assertEqual(x, [1, 2, 3, 4, 1, 2, 3, 4])
59 59
60 x = [1, 2, 3] 60 x = [1, 2, 3]
61 y = x 61 y = x
62 x[1:2] *= 2 62 x[1:2] *= 2
63 y[1:2] += [1] 63 y[1:2] += [1]
64 64
65 self.assertEqual(x, [1, 2, 1, 2, 3]) 65 self.assertEqual(x, [1, 2, 1, 2, 3])
66 self.assertTrue(x is y) 66 self.assertIs(x, y)
67 67
68 def testCustomMethods1(self): 68 def testCustomMethods1(self):
69 69
70 class aug_test: 70 class aug_test:
71 def __init__(self, value): 71 def __init__(self, value):
72 self.val = value 72 self.val = value
74 return self.val + val 74 return self.val + val
76 return aug_test(self.val + val) 76 return aug_test(self.val + val)
77 77
78 class aug_test2(aug_test): 78 class aug_test2(aug_test):
80 self.val = self.val + val 80 self.val = self.val + val
81 return self 81 return self
82 82
83 class aug_test3(aug_test): 83 class aug_test3(aug_test):
85 return aug_test3(self.val + val) 85 return aug_test3(self.val + val)
86 86
87 x = aug_test(1) 87 x = aug_test(1)
88 y = x 88 y = x
89 x += 10 89 x += 10
90 90
91 self.assertIsInstance(x, aug_test) 91 self.assertIsInstance(x, aug_test)
92 self.assertTrue(y is not x) 92 self.assertIsNot(y, x)
93 self.assertEqual(x.val, 11) 93 self.assertEqual(x.val, 11)
94 94
95 x = aug_test2(2) 95 x = aug_test2(2)
96 y = x 96 y = x
97 x += 10 97 x += 10
98 98
99 self.assertTrue(y is x) 99 self.assertIs(y, x)
100 self.assertEqual(x.val, 12) 100 self.assertEqual(x.val, 12)
101 101
102 x = aug_test3(3) 102 x = aug_test3(3)
103 y = x 103 y = x
104 x += 10 104 x += 10
105 105
106 self.assertIsInstance(x, aug_test3) 106 self.assertIsInstance(x, aug_test3)
107 self.assertTrue(y is not x) 107 self.assertIsNot(y, x)
108 self.assertEqual(x.val, 13) 108 self.assertEqual(x.val, 13)
109 109
110 110
111 def testCustomMethods2(test_self): 111 def testCustomMethods2(test_self):
112 output = [] 112 output = []
113 113
114 class testall: 114 class testall:
(...skipping 188 matching lines...)
306 __lshift__ called 306 __lshift__ called
307 __rlshift__ called 307 __rlshift__ called
308 __ilshift__ called 308 __ilshift__ called
309 '''.splitlines()) 309 '''.splitlines())
310 310
311 def test_main(): 311 def test_main():
312 run_unittest(AugAssignTest) 312 run_unittest(AugAssignTest)
313 313
314 if __name__ == '__main__': 314 if __name__ == '__main__':
315 test_main() 315 test_main()
OLDNEW
« no previous file with comments | « Lib/test/test_asyncore.py ('k') | Lib/test/test_bigmem.py » ('j') | no next file with comments »

This is Rietveld 894c83f36cb7+