Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-45249: Add regression test for display of SyntaxError range indicator in doctests #28567

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Lib/test/test_doctest3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import unittest
import io
import contextlib
import doctest

class TestDoctest(unittest.TestCase):
def test_syntax_error(self):
f = io.StringIO()
with contextlib.redirect_stdout(f):
doctest.run_docstring_examples('>>> 1 1', globals())
self.assertIn('''
1 1
^^^
SyntaxError: invalid syntax. Perhaps you forgot a comma?''',
f.getvalue())

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added regression test for caret indicators of :exc:`SyntaxError` errors
in :mod:`doctest`.