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

Delta Between Two Patch Sets: Lib/test/test_codeop.py

Issue 16510: Using appropriate checks in tests
Left Patch Set: Created 6 years, 9 months ago
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/test/test_cmd_line.py ('k') | Lib/test/test_compileall.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 """ 1 """
2 Test cases for codeop.py 2 Test cases for codeop.py
3 Nick Mathewson 3 Nick Mathewson
4 """ 4 """
5 import unittest 5 import unittest
6 from test.support import run_unittest, is_jython 6 from test.support import run_unittest, is_jython
7 7
8 from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT 8 from codeop import compile_command, PyCF_DONT_IMPLY_DEDENT
9 import io 9 import io
10 10
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 self.assertEqual(compile_command(str, "<input>", symbol), expected) 43 self.assertEqual(compile_command(str, "<input>", symbol), expected)
44 44
45 def assertIncomplete(self, str, symbol='single'): 45 def assertIncomplete(self, str, symbol='single'):
46 '''succeed iff str is the start of a valid piece of code''' 46 '''succeed iff str is the start of a valid piece of code'''
47 self.assertEqual(compile_command(str, symbol=symbol), None) 47 self.assertEqual(compile_command(str, symbol=symbol), None)
48 48
49 def assertInvalid(self, str, symbol='single', is_syntax=1): 49 def assertInvalid(self, str, symbol='single', is_syntax=1):
50 '''succeed iff str is the start of an invalid piece of code''' 50 '''succeed iff str is the start of an invalid piece of code'''
51 try: 51 try:
52 compile_command(str,symbol=symbol) 52 compile_command(str,symbol=symbol)
53 self.fail("No exception thrown for invalid code") 53 self.fail("No exception raised for invalid code")
54 except SyntaxError: 54 except SyntaxError:
55 self.assertTrue(is_syntax) 55 self.assertTrue(is_syntax)
56 except OverflowError: 56 except OverflowError:
57 self.assertFalse(is_syntax) 57 self.assertFalse(is_syntax)
58 58
59 def test_valid(self): 59 def test_valid(self):
60 av = self.assertValid 60 av = self.assertValid
61 61
62 # special case 62 # special case
63 if not is_jython: 63 if not is_jython:
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 self.assertNotEqual(compile_command("a = 1\n", "abc").co_filename, 295 self.assertNotEqual(compile_command("a = 1\n", "abc").co_filename,
296 compile("a = 1\n", "def", 'single').co_filename) 296 compile("a = 1\n", "def", 'single').co_filename)
297 297
298 298
299 def test_main(): 299 def test_main():
300 run_unittest(CodeopTests) 300 run_unittest(CodeopTests)
301 301
302 302
303 if __name__ == "__main__": 303 if __name__ == "__main__":
304 test_main() 304 test_main()
LEFTRIGHT

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