diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-07-27 20:30:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-27 20:30:32 (GMT) |
commit | ecc3c8e4216958d85385bf2467441c975128f26c (patch) | |
tree | cba394460a49c48aee128b4c9fe1b87c83b0b770 /Lib/test/test_print.py | |
parent | 6948964ecf94e858448dd28eea634317226d2913 (diff) | |
download | cpython-ecc3c8e4216958d85385bf2467441c975128f26c.zip cpython-ecc3c8e4216958d85385bf2467441c975128f26c.tar.gz cpython-ecc3c8e4216958d85385bf2467441c975128f26c.tar.bz2 |
bpo-34013: Move the Python 2 hints from the exception constructor to the parser (GH-27392)
Diffstat (limited to 'Lib/test/test_print.py')
-rw-r--r-- | Lib/test/test_print.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py index e838112..5f1bfd9 100644 --- a/Lib/test/test_print.py +++ b/Lib/test/test_print.py @@ -140,21 +140,24 @@ class TestPy2MigrationHint(unittest.TestCase): with self.assertRaises(SyntaxError) as context: exec(python2_print_str) - self.assertIn('print("Hello World")', str(context.exception)) + self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)", + str(context.exception)) def test_string_with_soft_space(self): python2_print_str = 'print "Hello World",' with self.assertRaises(SyntaxError) as context: exec(python2_print_str) - self.assertIn('print("Hello World", end=" ")', str(context.exception)) + self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)", + str(context.exception)) def test_string_with_excessive_whitespace(self): python2_print_str = 'print "Hello World", ' with self.assertRaises(SyntaxError) as context: exec(python2_print_str) - self.assertIn('print("Hello World", end=" ")', str(context.exception)) + self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)", + str(context.exception)) def test_string_with_leading_whitespace(self): python2_print_str = '''if 1: @@ -163,7 +166,8 @@ class TestPy2MigrationHint(unittest.TestCase): with self.assertRaises(SyntaxError) as context: exec(python2_print_str) - self.assertIn('print("Hello World")', str(context.exception)) + self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)", + str(context.exception)) # bpo-32685: Suggestions for print statement should be proper when # it is in the same line as the header of a compound statement @@ -173,14 +177,16 @@ class TestPy2MigrationHint(unittest.TestCase): with self.assertRaises(SyntaxError) as context: exec(python2_print_str) - self.assertIn('print(p)', str(context.exception)) + self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)", + str(context.exception)) def test_string_in_loop_on_same_line(self): python2_print_str = 'for i in s: print i' with self.assertRaises(SyntaxError) as context: exec(python2_print_str) - self.assertIn('print(i)', str(context.exception)) + self.assertIn("Missing parentheses in call to 'print'. Did you mean print(...)", + str(context.exception)) def test_stream_redirection_hint_for_py2_migration(self): # Test correct hint produced for Py2 redirection syntax |