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

Side by Side Diff: Lib/test/test_codeop.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_cmd_line.py ('k') | Lib/test/test_compileall.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 """ 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 raised 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.assertTrue(not 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:
64 self.assertEqual(compile_command(""), 64 self.assertEqual(compile_command(""),
65 compile("pass", "<input>", 'single', 65 compile("pass", "<input>", 'single',
66 PyCF_DONT_IMPLY_DEDENT)) 66 PyCF_DONT_IMPLY_DEDENT))
67 self.assertEqual(compile_command("\n"), 67 self.assertEqual(compile_command("\n"),
(...skipping 227 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()
OLDNEW
« no previous file with comments | « Lib/test/test_cmd_line.py ('k') | Lib/test/test_compileall.py » ('j') | no next file with comments »

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