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

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

Issue 16510: Using appropriate checks in tests
Patch Set: Created 5 years, 7 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_ossaudiodev.py ('k') | Lib/test/test_pep247.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 import dis 1 import dis
2 import re 2 import re
3 import sys 3 import sys
4 from io import StringIO 4 from io import StringIO
5 import unittest 5 import unittest
6 from math import copysign 6 from math import copysign
7 7
8 from test.bytecode_helper import BytecodeTestCase 8 from test.bytecode_helper import BytecodeTestCase
9 9
10 class TestTranforms(BytecodeTestCase): 10 class TestTranforms(BytecodeTestCase):
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 self.assertInBytecode(code, 'LOAD_CONST', elem) 134 self.assertInBytecode(code, 'LOAD_CONST', elem)
135 135
136 # Ensure that the resulting code actually works: 136 # Ensure that the resulting code actually works:
137 def f(a): 137 def f(a):
138 return a in {1, 2, 3} 138 return a in {1, 2, 3}
139 139
140 def g(a): 140 def g(a):
141 return a not in {1, 2, 3} 141 return a not in {1, 2, 3}
142 142
143 self.assertTrue(f(3)) 143 self.assertTrue(f(3))
144 self.assertTrue(not f(4)) 144 self.assertFalse(f(4))
145 145
146 self.assertTrue(not g(3)) 146 self.assertFalse(g(3))
147 self.assertTrue(g(4)) 147 self.assertTrue(g(4))
148 148
149 149
150 def test_folding_of_binops_on_constants(self): 150 def test_folding_of_binops_on_constants(self):
151 for line, elem in ( 151 for line, elem in (
152 ('a = 2+3+4', 9), # chained fold 152 ('a = 2+3+4', 9), # chained fold
153 ('"@"*4', '@@@@'), # check string ops 153 ('"@"*4', '@@@@'), # check string ops
154 ('a="abc" + "def"', 'abcdef'), # check string ops 154 ('a="abc" + "def"', 'abcdef'), # check string ops
155 ('a = 3**4', 81), # binary power 155 ('a = 3**4', 81), # binary power
156 ('a = 3*4', 12), # binary multiply 156 ('a = 3*4', 12), # binary multiply
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 import gc 330 import gc
331 counts = [None] * 5 331 counts = [None] * 5
332 for i in range(len(counts)): 332 for i in range(len(counts)):
333 support.run_unittest(*test_classes) 333 support.run_unittest(*test_classes)
334 gc.collect() 334 gc.collect()
335 counts[i] = sys.gettotalrefcount() 335 counts[i] = sys.gettotalrefcount()
336 print(counts) 336 print(counts)
337 337
338 if __name__ == "__main__": 338 if __name__ == "__main__":
339 test_main(verbose=True) 339 test_main(verbose=True)
OLDNEW
« no previous file with comments | « Lib/test/test_ossaudiodev.py ('k') | Lib/test/test_pep247.py » ('j') | no next file with comments »

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