diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_print.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_print.py b/Lib/test/test_print.py index 7bc23cf..e838112 100644 --- a/Lib/test/test_print.py +++ b/Lib/test/test_print.py @@ -165,6 +165,23 @@ class TestPy2MigrationHint(unittest.TestCase): self.assertIn('print("Hello World")', 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 + # and/or followed by a semicolon + def test_string_with_semicolon(self): + python2_print_str = 'print p;' + with self.assertRaises(SyntaxError) as context: + exec(python2_print_str) + + self.assertIn('print(p)', 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)) + def test_stream_redirection_hint_for_py2_migration(self): # Test correct hint produced for Py2 redirection syntax with self.assertRaises(TypeError) as context: |