Package: src:xdoctest
Version: 1.1.1-1
Severity: important
Tags: sid trixie
User: debian-pyt...@lists.debian.org
Usertags: python3.12

xdoctest's autopkg tests fail with Python 3.12:

[...]
209s autopkgtest [19:30:46]: test pytest: [-----------------------
209s === python3.12 ===
210s ============================= test session starts ==============================
210s platform linux -- Python 3.12.0+, pytest-7.4.3, pluggy-1.3.0
210s rootdir: /tmp/autopkgtest.XJHLC7/autopkgtest_tmp
210s configfile: pytest.ini
210s plugins: xdoctest-1.1.1
210s collected 226 items
210s
210s tests/test_binary_ext.py s [ 0%] 210s tests/test_cases.py ... [ 1%] 210s tests/test_checker.py ..... [ 3%] 210s tests/test_core.py ..........F.... [ 10%] 210s tests/test_directive.py .... [ 12%] 210s tests/test_doctest_example.py ....F....s.. [ 17%] 210s tests/test_dynamic.py .......... [ 22%] 210s tests/test_entry_point.py ... [ 23%] 210s tests/test_errors.py .F.. [ 25%] 210s tests/test_import.py . [ 25%] 210s tests/test_limitations.py . [ 26%] 210s tests/test_notebook.py ss [ 26%] 210s tests/test_parser.py ...F...F..........FF....F.......F. [ 42%] 213s tests/test_plugin.py .................s........F.........ssssss......... [ 64%] 214s ...............................ssssssss........ [ 85%] 214s tests/test_preimport.py . [ 85%] 218s tests/test_pytest_cli.py ........ [ 89%] 218s tests/test_runner.py ............ [ 94%] 218s tests/test_static.py ... [ 96%] 218s tests/test_traceback.py ...FF.... [100%]
218s
218s =================================== FAILURES =================================== 218s ____________________________ test_indented_grouping ____________________________
218s
218s self = <xdoctest.parser.DoctestParser object at 0x7f31819e2c60>
218s string = ">>> from xdoctest.utils import codeblock\n>>> # Simulate an indented part of code\n>>> if True:\n>>> # notice the...''\n... def foo():\n... return 'bar'\n... ''')\n>>> assert normal_version != codeblock_version" 218s info = {'callname': '<callname?>', 'fpath': None, 'lineno': 1, 'modpath': '<modpath?>'}
218s
218s     def parse(self, string, info=None):
218s         """
218s         Divide the given string into examples and interleaving text.
218s
218s         Args:
218s             string (str): string representing the doctest
218s info (dict | None): info about where the string came from in case of an
218s                 error
218s
218s         Returns:
218s             List[xdoctest.doctest_part.DoctestPart]:
218s                 a list of `DoctestPart` objects
218s
218s         CommandLine:
218s             python -m xdoctest.parser DoctestParser.parse
218s
218s         Example:
218s             >>> s = 'I am a dummy example with two parts'
218s             >>> x = 10
218s             >>> print(s)
218s             I am a dummy example with two parts
218s             >>> s = 'My purpose it so demonstrate how wants work here'
218s             >>> print('The new want applies ONLY to stdout')
218s             >>> print('given before the last want')
218s             >>> '''
218s                 this wont hurt the test at all
218s                 even though its multiline '''
218s             >>> y = 20
218s             The new want applies ONLY to stdout
218s             given before the last want
218s >>> # Parts from previous examples are executed in the same context
218s             >>> print(x + y)
218s             30
218s
218s this is simply text, and doesnt apply to the previous doctest the
218s             <BLANKLINE> directive is still in effect.
218s
218s         Example:
218s             >>> from xdoctest.parser import *  # NOQA
218s             >>> from xdoctest import parser
218s             >>> from xdoctest.docstr import docscrape_google
218s             >>> from xdoctest import core
218s             >>> self = parser.DoctestParser()
218s             >>> docstr = self.parse.__doc__
218s >>> blocks = docscrape_google.split_google_docblocks(docstr)
218s             >>> doclineno = self.parse.__func__.__code__.co_firstlineno
218s             >>> key, (string, offset) = blocks[-2]
218s             >>> self._label_docsrc_lines(string)
218s             >>> doctest_parts = self.parse(string)
218s >>> # each part with a want-string needs to be broken in two
218s             >>> assert len(doctest_parts) == 6
218s             >>> len(doctest_parts)
218s         """
218s         if global_state.DEBUG_PARSER > 1:
218s             print('\n===== PARSE ====')
218s         if sys.version_info.major == 2:  # nocover
218s             string = utils.ensure_unicode(string)
218s
218s         if not isinstance(string, six.string_types):
218s raise TypeError('Expected string but got {!r}'.format(string))
218s
218s         string = string.expandtabs()
218s         # If all lines begin with the same indentation, then strip it.
218s         min_indent = _min_indentation(string)
218s         if min_indent > 0:
218s string = '\n'.join([ln[min_indent:] for ln in string.splitlines()])
218s
218s         labeled_lines = None
218s         grouped_lines = None
218s         all_parts = None
218s         try:
218s >           labeled_lines = self._label_docsrc_lines(string)
218s
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:170:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:836: in _label_docsrc_lines 218s for part, norm_line in _complete_source(line, state_indent, line_iter): 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:918: in _complete_source 218s while not static.is_balanced_statement(source_parts, only_tokens=True): 218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:941: in is_balanced_statement
218s     for t in tokenize.generate_tokens(_readline):
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s source = <function is_balanced_statement.<locals>._readline at 0x7f3181114720>
218s encoding = None, extra_tokens = True
218s
218s def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False): 218s """Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
218s         if encoding is None:
218s it = _tokenize.TokenizerIter(source, extra_tokens=extra_tokens)
218s         else:
218s it = _tokenize.TokenizerIter(source, encoding=encoding, extra_tokens=extra_tokens)
218s         try:
218s             for info in it:
218s                 yield TokenInfo._make(info)
218s         except SyntaxError as e:
218s             if type(e) != SyntaxError:
218s                 raise e from None
218s             msg = _transform_msg(e.msg)
218s >           raise TokenError(msg, (e.lineno, e.offset)) from None
218s E tokenize.TokenError: ('unexpected EOF in multi-line statement', (1, 0))
218s
218s /usr/lib/python3.12/tokenize.py:543: TokenError
218s
218s During handling of the above exception, another exception occurred:
218s
218s     def test_indented_grouping():
218s         """
218s Initial changes in 0.10.0 broke parsing of some ubelt tests, check to 218s ensure using `...` in indented blocks is ok (as long as there is no want
218s         string in the indented block).
218s
218s         CommandLine:
218s xdoctest -m ~/code/xdoctest/tests/test_core.py test_indented_grouping
218s         """
218s         from xdoctest.doctest_example import DocTest
218s         example = DocTest(
218s             utils.codeblock(r"""
218s             >>> from xdoctest.utils import codeblock
218s             >>> # Simulate an indented part of code
218s             >>> if True:
218s             >>>     # notice the indentation on this will be normal
218s             >>>     codeblock_version = codeblock(
218s             ...             '''
218s             ...             def foo():
218s             ...                 return 'bar'
218s             ...             '''
218s             ...         )
218s >>> # notice the indentation and newlines on this will be odd
218s             >>>     normal_version = ('''
218s             ...         def foo():
218s             ...             return 'bar'
218s             ...     ''')
218s             >>> assert normal_version != codeblock_version
218s             """))
218s         # print(example.format_src())
218s >       status = example.run(verbose=0)
218s
218s tests/test_core.py:449:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s /usr/lib/python3/dist-packages/xdoctest/doctest_example.py:662: in run
218s     self._parse()  # parse out parts if we have not already done so
218s /usr/lib/python3/dist-packages/xdoctest/doctest_example.py:540: in _parse
218s     self._parts = parser.DoctestParser().parse(self.docsrc, info)
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s self = <xdoctest.parser.DoctestParser object at 0x7f31819e2c60>
218s string = ">>> from xdoctest.utils import codeblock\n>>> # Simulate an indented part of code\n>>> if True:\n>>> # notice the...''\n... def foo():\n... return 'bar'\n... ''')\n>>> assert normal_version != codeblock_version" 218s info = {'callname': '<callname?>', 'fpath': None, 'lineno': 1, 'modpath': '<modpath?>'}
218s
218s     def parse(self, string, info=None):
218s         """
218s         Divide the given string into examples and interleaving text.
218s
218s         Args:
218s             string (str): string representing the doctest
218s info (dict | None): info about where the string came from in case of an
218s                 error
218s
218s         Returns:
218s             List[xdoctest.doctest_part.DoctestPart]:
218s                 a list of `DoctestPart` objects
218s
218s         CommandLine:
218s             python -m xdoctest.parser DoctestParser.parse
218s
218s         Example:
218s             >>> s = 'I am a dummy example with two parts'
218s             >>> x = 10
218s             >>> print(s)
218s             I am a dummy example with two parts
218s             >>> s = 'My purpose it so demonstrate how wants work here'
218s             >>> print('The new want applies ONLY to stdout')
218s             >>> print('given before the last want')
218s             >>> '''
218s                 this wont hurt the test at all
218s                 even though its multiline '''
218s             >>> y = 20
218s             The new want applies ONLY to stdout
218s             given before the last want
218s >>> # Parts from previous examples are executed in the same context
218s             >>> print(x + y)
218s             30
218s
218s this is simply text, and doesnt apply to the previous doctest the
218s             <BLANKLINE> directive is still in effect.
218s
218s         Example:
218s             >>> from xdoctest.parser import *  # NOQA
218s             >>> from xdoctest import parser
218s             >>> from xdoctest.docstr import docscrape_google
218s             >>> from xdoctest import core
218s             >>> self = parser.DoctestParser()
218s             >>> docstr = self.parse.__doc__
218s >>> blocks = docscrape_google.split_google_docblocks(docstr)
218s             >>> doclineno = self.parse.__func__.__code__.co_firstlineno
218s             >>> key, (string, offset) = blocks[-2]
218s             >>> self._label_docsrc_lines(string)
218s             >>> doctest_parts = self.parse(string)
218s >>> # each part with a want-string needs to be broken in two
218s             >>> assert len(doctest_parts) == 6
218s             >>> len(doctest_parts)
218s         """
218s         if global_state.DEBUG_PARSER > 1:
218s             print('\n===== PARSE ====')
218s         if sys.version_info.major == 2:  # nocover
218s             string = utils.ensure_unicode(string)
218s
218s         if not isinstance(string, six.string_types):
218s raise TypeError('Expected string but got {!r}'.format(string))
218s
218s         string = string.expandtabs()
218s         # If all lines begin with the same indentation, then strip it.
218s         min_indent = _min_indentation(string)
218s         if min_indent > 0:
218s string = '\n'.join([ln[min_indent:] for ln in string.splitlines()])
218s
218s         labeled_lines = None
218s         grouped_lines = None
218s         all_parts = None
218s         try:
218s             labeled_lines = self._label_docsrc_lines(string)
218s             grouped_lines = self._group_labeled_lines(labeled_lines)
218s             all_parts = list(self._package_groups(grouped_lines))
218s         except Exception as orig_ex:
218s
218s             if labeled_lines is None:
218s                 failpoint = '_label_docsrc_lines'
218s             elif grouped_lines is None:
218s                 failpoint = '_group_labeled_lines'
218s             elif all_parts is None:
218s                 failpoint = '_package_groups'
218s             if global_state.DEBUG_PARSER:
218s                 print('<FAILPOINT>')
218s                 print('!!! FAILED !!!')
218s                 print('failpoint = {!r}'.format(failpoint))
218s
218s                 import ubelt as ub
218s                 import traceback
218s                 tb_text = traceback.format_exc()
218s                 tb_text = ub.highlight_code(tb_text)
218s                 tb_text = ub.indent(tb_text)
218s                 print(tb_text)
218s
218s print('Failed to parse string = <{[<{[<{[ # xdoc debug')
218s                 print(string)
218s                 print(']}>]}>]}>  # xdoc debug end string')
218s
218s                 print('info = {}'.format(ub.repr2(info)))
218s                 print('-----')
218s                 print('orig_ex = {}'.format(orig_ex))
218s print('labeled_lines = {}'.format(ub.repr2(labeled_lines))) 218s print('grouped_lines = {}'.format(ub.repr2(grouped_lines, nl=3)))
218s                 print('all_parts = {}'.format(ub.repr2(all_parts)))
218s                 print('</FAILPOINT>')
218s                 # sys.exit(1)
218s >           raise exceptions.DoctestParseError(
218s                 'Failed to parse doctest in {}'.format(failpoint),
218s                 string=string, info=info, orig_ex=orig_ex)
218s E xdoctest.exceptions.DoctestParseError: Failed to parse doctest in _label_docsrc_lines
218s
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:205: DoctestParseError 218s _____________________________ test_multiline_list ______________________________
218s
218s self = <xdoctest.parser.DoctestParser object at 0x7f31819bdeb0>
218s string = '>>> x = [1, 2, 3,\n>>>      4, 5, 6]\n>>> print(len(x))\n6'
218s info = {'callname': '<callname?>', 'fpath': None, 'lineno': 1, 'modpath': '<modpath?>'}
218s
218s     def parse(self, string, info=None):
218s         """
218s         Divide the given string into examples and interleaving text.
218s
218s         Args:
218s             string (str): string representing the doctest
218s info (dict | None): info about where the string came from in case of an
218s                 error
218s
218s         Returns:
218s             List[xdoctest.doctest_part.DoctestPart]:
218s                 a list of `DoctestPart` objects
218s
218s         CommandLine:
218s             python -m xdoctest.parser DoctestParser.parse
218s
218s         Example:
218s             >>> s = 'I am a dummy example with two parts'
218s             >>> x = 10
218s             >>> print(s)
218s             I am a dummy example with two parts
218s             >>> s = 'My purpose it so demonstrate how wants work here'
218s             >>> print('The new want applies ONLY to stdout')
218s             >>> print('given before the last want')
218s             >>> '''
218s                 this wont hurt the test at all
218s                 even though its multiline '''
218s             >>> y = 20
218s             The new want applies ONLY to stdout
218s             given before the last want
218s >>> # Parts from previous examples are executed in the same context
218s             >>> print(x + y)
218s             30
218s
218s this is simply text, and doesnt apply to the previous doctest the
218s             <BLANKLINE> directive is still in effect.
218s
218s         Example:
218s             >>> from xdoctest.parser import *  # NOQA
218s             >>> from xdoctest import parser
218s             >>> from xdoctest.docstr import docscrape_google
218s             >>> from xdoctest import core
218s             >>> self = parser.DoctestParser()
218s             >>> docstr = self.parse.__doc__
218s >>> blocks = docscrape_google.split_google_docblocks(docstr)
218s             >>> doclineno = self.parse.__func__.__code__.co_firstlineno
218s             >>> key, (string, offset) = blocks[-2]
218s             >>> self._label_docsrc_lines(string)
218s             >>> doctest_parts = self.parse(string)
218s >>> # each part with a want-string needs to be broken in two
218s             >>> assert len(doctest_parts) == 6
218s             >>> len(doctest_parts)
218s         """
218s         if global_state.DEBUG_PARSER > 1:
218s             print('\n===== PARSE ====')
218s         if sys.version_info.major == 2:  # nocover
218s             string = utils.ensure_unicode(string)
218s
218s         if not isinstance(string, six.string_types):
218s raise TypeError('Expected string but got {!r}'.format(string))
218s
218s         string = string.expandtabs()
218s         # If all lines begin with the same indentation, then strip it.
218s         min_indent = _min_indentation(string)
218s         if min_indent > 0:
218s string = '\n'.join([ln[min_indent:] for ln in string.splitlines()])
218s
218s         labeled_lines = None
218s         grouped_lines = None
218s         all_parts = None
218s         try:
218s >           labeled_lines = self._label_docsrc_lines(string)
218s
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:170:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:836: in _label_docsrc_lines 218s for part, norm_line in _complete_source(line, state_indent, line_iter): 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:918: in _complete_source 218s while not static.is_balanced_statement(source_parts, only_tokens=True): 218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:941: in is_balanced_statement
218s     for t in tokenize.generate_tokens(_readline):
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s source = <function is_balanced_statement.<locals>._readline at 0x7f3181114900>
218s encoding = None, extra_tokens = True
218s
218s def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False): 218s """Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
218s         if encoding is None:
218s it = _tokenize.TokenizerIter(source, extra_tokens=extra_tokens)
218s         else:
218s it = _tokenize.TokenizerIter(source, encoding=encoding, extra_tokens=extra_tokens)
218s         try:
218s             for info in it:
218s                 yield TokenInfo._make(info)
218s         except SyntaxError as e:
218s             if type(e) != SyntaxError:
218s                 raise e from None
218s             msg = _transform_msg(e.msg)
218s >           raise TokenError(msg, (e.lineno, e.offset)) from None
218s E tokenize.TokenError: ('unexpected EOF in multi-line statement', (1, 0))
218s
218s /usr/lib/python3.12/tokenize.py:543: TokenError
218s
218s During handling of the above exception, another exception occurred:
218s
218s     def test_multiline_list():
218s         """
218s         pytest tests/test_doctest_example.py::test_multiline_list
218s         """
218s         string = utils.codeblock(
218s             '''
218s             >>> x = [1, 2, 3,
218s             >>>      4, 5, 6]
218s             >>> print(len(x))
218s             6
218s             ''')
218s         self = doctest_example.DocTest(docsrc=string)
218s >       result = self.run(on_error='raise')
218s
218s tests/test_doctest_example.py:91:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s /usr/lib/python3/dist-packages/xdoctest/doctest_example.py:662: in run
218s     self._parse()  # parse out parts if we have not already done so
218s /usr/lib/python3/dist-packages/xdoctest/doctest_example.py:540: in _parse
218s     self._parts = parser.DoctestParser().parse(self.docsrc, info)
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s self = <xdoctest.parser.DoctestParser object at 0x7f31819bdeb0>
218s string = '>>> x = [1, 2, 3,\n>>>      4, 5, 6]\n>>> print(len(x))\n6'
218s info = {'callname': '<callname?>', 'fpath': None, 'lineno': 1, 'modpath': '<modpath?>'}
218s
218s     def parse(self, string, info=None):
218s         """
218s         Divide the given string into examples and interleaving text.
218s
218s         Args:
218s             string (str): string representing the doctest
218s info (dict | None): info about where the string came from in case of an
218s                 error
218s
218s         Returns:
218s             List[xdoctest.doctest_part.DoctestPart]:
218s                 a list of `DoctestPart` objects
218s
218s         CommandLine:
218s             python -m xdoctest.parser DoctestParser.parse
218s
218s         Example:
218s             >>> s = 'I am a dummy example with two parts'
218s             >>> x = 10
218s             >>> print(s)
218s             I am a dummy example with two parts
218s             >>> s = 'My purpose it so demonstrate how wants work here'
218s             >>> print('The new want applies ONLY to stdout')
218s             >>> print('given before the last want')
218s             >>> '''
218s                 this wont hurt the test at all
218s                 even though its multiline '''
218s             >>> y = 20
218s             The new want applies ONLY to stdout
218s             given before the last want
218s >>> # Parts from previous examples are executed in the same context
218s             >>> print(x + y)
218s             30
218s
218s this is simply text, and doesnt apply to the previous doctest the
218s             <BLANKLINE> directive is still in effect.
218s
218s         Example:
218s             >>> from xdoctest.parser import *  # NOQA
218s             >>> from xdoctest import parser
218s             >>> from xdoctest.docstr import docscrape_google
218s             >>> from xdoctest import core
218s             >>> self = parser.DoctestParser()
218s             >>> docstr = self.parse.__doc__
218s >>> blocks = docscrape_google.split_google_docblocks(docstr)
218s             >>> doclineno = self.parse.__func__.__code__.co_firstlineno
218s             >>> key, (string, offset) = blocks[-2]
218s             >>> self._label_docsrc_lines(string)
218s             >>> doctest_parts = self.parse(string)
218s >>> # each part with a want-string needs to be broken in two
218s             >>> assert len(doctest_parts) == 6
218s             >>> len(doctest_parts)
218s         """
218s         if global_state.DEBUG_PARSER > 1:
218s             print('\n===== PARSE ====')
218s         if sys.version_info.major == 2:  # nocover
218s             string = utils.ensure_unicode(string)
218s
218s         if not isinstance(string, six.string_types):
218s raise TypeError('Expected string but got {!r}'.format(string))
218s
218s         string = string.expandtabs()
218s         # If all lines begin with the same indentation, then strip it.
218s         min_indent = _min_indentation(string)
218s         if min_indent > 0:
218s string = '\n'.join([ln[min_indent:] for ln in string.splitlines()])
218s
218s         labeled_lines = None
218s         grouped_lines = None
218s         all_parts = None
218s         try:
218s             labeled_lines = self._label_docsrc_lines(string)
218s             grouped_lines = self._group_labeled_lines(labeled_lines)
218s             all_parts = list(self._package_groups(grouped_lines))
218s         except Exception as orig_ex:
218s
218s             if labeled_lines is None:
218s                 failpoint = '_label_docsrc_lines'
218s             elif grouped_lines is None:
218s                 failpoint = '_group_labeled_lines'
218s             elif all_parts is None:
218s                 failpoint = '_package_groups'
218s             if global_state.DEBUG_PARSER:
218s                 print('<FAILPOINT>')
218s                 print('!!! FAILED !!!')
218s                 print('failpoint = {!r}'.format(failpoint))
218s
218s                 import ubelt as ub
218s                 import traceback
218s                 tb_text = traceback.format_exc()
218s                 tb_text = ub.highlight_code(tb_text)
218s                 tb_text = ub.indent(tb_text)
218s                 print(tb_text)
218s
218s print('Failed to parse string = <{[<{[<{[ # xdoc debug')
218s                 print(string)
218s                 print(']}>]}>]}>  # xdoc debug end string')
218s
218s                 print('info = {}'.format(ub.repr2(info)))
218s                 print('-----')
218s                 print('orig_ex = {}'.format(orig_ex))
218s print('labeled_lines = {}'.format(ub.repr2(labeled_lines))) 218s print('grouped_lines = {}'.format(ub.repr2(grouped_lines, nl=3)))
218s                 print('all_parts = {}'.format(ub.repr2(all_parts)))
218s                 print('</FAILPOINT>')
218s                 # sys.exit(1)
218s >           raise exceptions.DoctestParseError(
218s                 'Failed to parse doctest in {}'.format(failpoint),
218s                 string=string, info=info, orig_ex=orig_ex)
218s E xdoctest.exceptions.DoctestParseError: Failed to parse doctest in _label_docsrc_lines
218s
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:205: DoctestParseError 218s ___________________________ test_runner_syntax_error ___________________________
218s
218s     def test_runner_syntax_error():
218s         """
218s             python tests/test_errors.py test_runner_syntax_error
218s
218s             xdoctest -m tests/test_errors.py test_runner_syntax_error
218s         """
218s         source = utils.codeblock(
218s             r'''
218s             def demo_parsetime_syntax_error1():
218s                 """
218s                     Example:
218s                         >>> from __future__ import print_function
218s                         >>> print 'Parse-Time Syntax Error'
218s                 """
218s
218s             def demo_parsetime_syntax_error2():
218s                 """
218s                     Example:
218s                         >>> def bad_syntax() return for
218s                 """
218s
218s             def demo_runtime_error():
218s                 """
218s                     Example:
218s                         >>> print('Runtime Error {}'.format(5 / 0))
218s                 """
218s
218s             def demo_runtime_name_error():
218s                 """
218s                     Example:
218s                         >>> print('Name Error {}'.format(foo))
218s                 """
218s
218s             def demo_runtime_warning():
218s                 """
218s                     Example:
218s                         >>> import warnings
218s                         >>> warnings.warn('in-code warning')
218s                 """
218s             ''')
218s
218s         temp = utils.TempDir(persist=True)
218s         temp.ensure()
218s         dpath = temp.dpath
218s         modpath = join(dpath, 'demo_runner_syntax_error.py')
218s         with open(modpath, 'w') as file:
218s             file.write(source)
218s
218s         with utils.CaptureStdout() as cap:
218s runner.doctest_module(modpath, 'all', argv=[''], style='freeform',
218s                                   verbose=1)
218s
218s         print('CAPTURED [[[[[[[[')
218s         print(utils.indent(cap.text))
218s         print(']]]]]]]] # CAPTURED')
218s
218s         if six.PY2:
218s             captext = utils.ensure_unicode(cap.text)
218s         else:
218s             captext = cap.text
218s
218s if True or not six.PY2: # Why does this have issues on the dashboards?
218s             assert '1 run-time warnings' in captext
218s >           assert '2 parse-time warnings' in captext
218s E AssertionError: assert '2 parse-time warnings' in 'msg = Cannot scrape callname=demo_parsetime_syntax_error1 in modpath=/tmp/tmpj_tfuers/demo_runner_syntax_error.py lin...tfuers/demo_runner_syntax_error.py demo_runtime_name_error:0\n=== 2 failed, 1 passed, 8 warnings in 0.00 seconds ===\n'
218s
218s tests/test_errors.py:168: AssertionError
218s ----------------------------- Captured stdout call -----------------------------
218s CAPTURED [[[[[[[[
218s msg = Cannot scrape callname=demo_parsetime_syntax_error1 in modpath=/tmp/tmpj_tfuers/demo_runner_syntax_error.py line=2. 218s Caused by: DoctestParseError('Failed to parse doctest in _package_groups')
218s
218s     Example:
218s         >>> from __future__ import print_function
218s         >>> print 'Parse-Time Syntax Error'
218s
218s Original Error: SyntaxError("Missing parentheses in call to 'print'. Did you mean print(...)?", ('<source_block>', 2, 1, "print 'Parse-Time Syntax Error'\n", 2, 32))
218s
218s     print 'Parse-Time Syntax Error'
218s     ^
218s msg = Cannot scrape callname=demo_parsetime_syntax_error2 in modpath=/tmp/tmpj_tfuers/demo_runner_syntax_error.py line=9. 218s Caused by: DoctestParseError('Failed to parse doctest in _package_groups')
218s
218s     Example:
218s         >>> def bad_syntax() return for
218s
218s Original Error: SyntaxError("expected ':'", ('<source_block>', 1, 18, 'def bad_syntax() return for\n', 1, 24))
218s
218s     def bad_syntax() return for
218s                      ^
218s     running 3 test(s)
218s * DOCTEST : /tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_error:0, line 17 <- wrt source file 218s * FAILURE: /tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_error:0 218s * DOCTEST : /tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_name_error:0, line 23 <- wrt source file 218s * FAILURE: /tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_name_error:0 218s * DOCTEST : /tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_warning:0, line 29 <- wrt source file 218s * SUCCESS: /tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_warning:0
218s     ============
218s     Finished doctests
218s     1 / 3 passed
218s
218s     === Found 7 parse-time warnings ===
218s     --- Parse Warning: 1 / 7 ---
218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s           docstr = utils.ensure_unicode(docnode.value.s)
218s
218s     --- Parse Warning: 2 / 7 ---
218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s           docstr = utils.ensure_unicode(docnode.value.s)
218s
218s     --- Parse Warning: 3 / 7 ---
218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s           docstr = utils.ensure_unicode(docnode.value.s)
218s
218s     --- Parse Warning: 4 / 7 ---
218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s           docstr = utils.ensure_unicode(docnode.value.s)
218s
218s     --- Parse Warning: 5 / 7 ---
218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s           docstr = utils.ensure_unicode(docnode.value.s)
218s
218s     --- Parse Warning: 6 / 7 ---
218s /usr/lib/python3/dist-packages/xdoctest/core.py:426: UserWarning: Cannot scrape callname=demo_parsetime_syntax_error1 in modpath=/tmp/tmpj_tfuers/demo_runner_syntax_error.py line=2. 218s Caused by: DoctestParseError('Failed to parse doctest in _package_groups')
218s
218s         Example:
218s             >>> from __future__ import print_function
218s             >>> print 'Parse-Time Syntax Error'
218s
218s Original Error: SyntaxError("Missing parentheses in call to 'print'. Did you mean print(...)?", ('<source_block>', 2, 1, "print 'Parse-Time Syntax Error'\n", 2, 32))
218s
218s         print 'Parse-Time Syntax Error'
218s         ^
218s           warnings.warn(msg)
218s
218s     --- Parse Warning: 7 / 7 ---
218s /usr/lib/python3/dist-packages/xdoctest/core.py:426: UserWarning: Cannot scrape callname=demo_parsetime_syntax_error2 in modpath=/tmp/tmpj_tfuers/demo_runner_syntax_error.py line=9. 218s Caused by: DoctestParseError('Failed to parse doctest in _package_groups')
218s
218s         Example:
218s             >>> def bad_syntax() return for
218s
218s Original Error: SyntaxError("expected ':'", ('<source_block>', 1, 18, 'def bad_syntax() return for\n', 1, 24))
218s
218s         def bad_syntax() return for
218s                          ^
218s           warnings.warn(msg)
218s
218s
218s     === Found 1 run-time warnings ===
218s     --- Runtime Warning: 1 / 1 ---
218s example = <DocTest(demo_runner_syntax_error demo_runtime_warning:0 ln 29) at 0x7f31819cf5c0> 218s <doctest:/tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_warning:0>:2: UserWarning: in-code warning
218s
218s
218s     === Found 2 errors ===
218s     --- Error: 1 / 2 ---
218s         * REASON: ZeroDivisionError
218s         DOCTEST DEBUG INFO
218s XDoc "/tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_error:0", line 1 <- wrt doctest 218s File "/tmp/tmpj_tfuers/demo_runner_syntax_error.py", line 17, <- wrt source file
218s         DOCTEST PART BREAKDOWN
218s         Failed Part:
218s             1 >>> print('Runtime Error {}'.format(5 / 0))
218s         DOCTEST TRACEBACK
218s         Traceback (most recent call last):
218s
218s File "/usr/lib/python3/dist-packages/xdoctest/doctest_example.py", line 811, in run
218s             exec(code, test_globals)
218s
218s File "<doctest:/tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_error:0>", line rel: 1, abs: 17, in <module>
218s             >>> print('Runtime Error {}'.format(5 / 0))
218s
218s         ZeroDivisionError: division by zero
218s
218s         DOCTEST REPRODUCTION
218s         CommandLine:
218s python -m xdoctest /tmp/tmpj_tfuers/demo_runner_syntax_error.py demo_runtime_error:0
218s     --- Error: 2 / 2 ---
218s         * REASON: NameError
218s         DOCTEST DEBUG INFO
218s XDoc "/tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_name_error:0", line 1 <- wrt doctest 218s File "/tmp/tmpj_tfuers/demo_runner_syntax_error.py", line 23, <- wrt source file
218s         DOCTEST PART BREAKDOWN
218s         Failed Part:
218s             1 >>> print('Name Error {}'.format(foo))
218s         DOCTEST TRACEBACK
218s         Traceback (most recent call last):
218s
218s File "/usr/lib/python3/dist-packages/xdoctest/doctest_example.py", line 811, in run
218s             exec(code, test_globals)
218s
218s File "<doctest:/tmp/tmpj_tfuers/demo_runner_syntax_error.py::demo_runtime_name_error:0>", line rel: 1, abs: 23, in <module>
218s             >>> print('Name Error {}'.format(foo))
218s
218s         NameError: name 'foo' is not defined
218s
218s         DOCTEST REPRODUCTION
218s         CommandLine:
218s python -m xdoctest /tmp/tmpj_tfuers/demo_runner_syntax_error.py demo_runtime_name_error:0
218s
218s     === Failed tests ===
218s python -m xdoctest /tmp/tmpj_tfuers/demo_runner_syntax_error.py demo_runtime_error:0 218s python -m xdoctest /tmp/tmpj_tfuers/demo_runner_syntax_error.py demo_runtime_name_error:0
218s     === 2 failed, 1 passed, 8 warnings in 0.00 seconds ===
218s
218s ]]]]]]]] # CAPTURED
218s __________________________ test_label_indented_lines ___________________________
218s
218s     def test_label_indented_lines():
218s         string = '''
218s                 text
218s                 >>> dsrc1()
218s                 want
218s
218s                     >>> dsrc2()
218s                     >>> cont(
218s                     ... a=b)
218s                     ... dsrc
218s                     >>> dsrc3():
218s                     ...     a
218s                     ...     b = """
218s                             multiline
218s                             """
218s                     want
218s
218s                 text
218s                 ... still text
218s                 >>> "now its a doctest"
218s
218s                 text
218s         '''
218s         self = parser.DoctestParser()
218s >       labeled = self._label_docsrc_lines(string)
218s
218s tests/test_parser.py:139:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:836: in _label_docsrc_lines 218s for part, norm_line in _complete_source(line, state_indent, line_iter): 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:918: in _complete_source 218s while not static.is_balanced_statement(source_parts, only_tokens=True): 218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:941: in is_balanced_statement
218s     for t in tokenize.generate_tokens(_readline):
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s source = <function is_balanced_statement.<locals>._readline at 0x7f31811172e0>
218s encoding = None, extra_tokens = True
218s
218s def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False): 218s """Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
218s         if encoding is None:
218s it = _tokenize.TokenizerIter(source, extra_tokens=extra_tokens)
218s         else:
218s it = _tokenize.TokenizerIter(source, encoding=encoding, extra_tokens=extra_tokens)
218s         try:
218s             for info in it:
218s                 yield TokenInfo._make(info)
218s         except SyntaxError as e:
218s             if type(e) != SyntaxError:
218s                 raise e from None
218s             msg = _transform_msg(e.msg)
218s >           raise TokenError(msg, (e.lineno, e.offset)) from None
218s E tokenize.TokenError: ('unexpected EOF in multi-line statement', (1, 0))
218s
218s /usr/lib/python3.12/tokenize.py:543: TokenError
218s ______________________________ test_ps1_linenos_4 ______________________________
218s
218s     def test_ps1_linenos_4():
218s         source_lines = utils.codeblock(
218s             '''
218s             >>> x = """
218s                 x = 2
218s                 """
218s             >>> def foo():
218s             ...     return 5
218s             >>> ms1 = """
218s             ... multistring2
218s             ... multistring2
218s             ... """
218s             >>> ms2 = """
218s             ... multistring2
218s             ... multistring2
218s             ... """
218s             >>> x = sum([
218s             >>>     foo()
218s             >>> ])
218s             >>> y = len(ms1) + len(ms2)
218s             >>> z = (
218s             >>>     x + y
218s             >>> )
218s             >>> z
218s             59
218s             ''').split('\n')[:-1]
218s         self = parser.DoctestParser()
218s >       linenos, mode_hint = self._locate_ps1_linenos(source_lines)
218s
218s tests/test_parser.py:255:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:555: in _locate_ps1_linenos 218s exec_source_lines = list(_hack_comment_statements(exec_source_lines)) 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:545: in _hack_comment_statements
218s     intervals = balanced_intervals(lines)
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:533: in balanced_intervals 218s while not static.is_balanced_statement(lines[a:b], only_tokens=True) and a >= 0: 218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:941: in is_balanced_statement
218s     for t in tokenize.generate_tokens(_readline):
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s source = <function is_balanced_statement.<locals>._readline at 0x7f3181117b00>
218s encoding = None, extra_tokens = True
218s
218s def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False): 218s """Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
218s         if encoding is None:
218s it = _tokenize.TokenizerIter(source, extra_tokens=extra_tokens)
218s         else:
218s it = _tokenize.TokenizerIter(source, encoding=encoding, extra_tokens=extra_tokens)
218s         try:
218s             for info in it:
218s                 yield TokenInfo._make(info)
218s         except SyntaxError as e:
218s             if type(e) != SyntaxError:
218s                 raise e from None
218s             msg = _transform_msg(e.msg)
218s >           raise TokenError(msg, (e.lineno, e.offset)) from None
218s E tokenize.TokenError: ('unexpected EOF in multi-line statement', (1, 0))
218s
218s /usr/lib/python3.12/tokenize.py:543: TokenError
218s __________________________ test_nonbalanced_statement __________________________
218s
218s     def test_nonbalanced_statement():
218s         """
218s xdoctest ~/code/xdoctest/tests/test_parser.py test_nonbalanced_statement
218s
218s         from xdoctest import static_analysis as static
218s         lines = ['x = [']
218s         static.is_balanced_statement(lines, only_tokens=True)
218s         """
218s         string = utils.codeblock(
218s             '''
218s             >>> x = [
218s # ] this braket is to make my editor happy and is does not effect the test
218s             ''').splitlines()[0]
218s
218s         self = parser.DoctestParser()
218s         with pytest.raises(exceptions.DoctestParseError) as exc_info:
218s             self.parse(string)
218s >       msg = exc_info.value.orig_ex.msg.lower()
218s E       AttributeError: 'TokenError' object has no attribute 'msg'
218s
218s tests/test_parser.py:438: AttributeError
218s _______________________________ test_bad_indent ________________________________
218s
218s     def test_bad_indent():
218s         """
218s         CommandLine:
218s             python tests/test_parser.py test_bad_indent
218s         """
218s         string = utils.codeblock(
218s             '''
218s             Example:
218s                 >>> x = [
218s             # ] bad want indent
218s             ''')
218s
218s         self = parser.DoctestParser()
218s         with pytest.raises(exceptions.DoctestParseError) as exc_info:
218s             self.parse(string)
218s >       msg = exc_info.value.orig_ex.msg.lower()
218s E       AttributeError: 'TokenError' object has no attribute 'msg'
218s
218s tests/test_parser.py:457: AttributeError
218s ____________________________ test_inline_directive _____________________________
218s
218s self = <xdoctest.parser.DoctestParser object at 0x7f318199e690>
218s string = '>>> # doctest: +SKIP\n>>> func1(*\n>>> [i for i in range(10)])\n>>> # not a directive\n>>> func2( # not a directi...\' # doctest: not a directive\')\n>>> func9("""\n # doctest: still not a directive\n """)\nfinalwant'
218s info = None
218s
218s     def parse(self, string, info=None):
218s         """
218s         Divide the given string into examples and interleaving text.
218s
218s         Args:
218s             string (str): string representing the doctest
218s info (dict | None): info about where the string came from in case of an
218s                 error
218s
218s         Returns:
218s             List[xdoctest.doctest_part.DoctestPart]:
218s                 a list of `DoctestPart` objects
218s
218s         CommandLine:
218s             python -m xdoctest.parser DoctestParser.parse
218s
218s         Example:
218s             >>> s = 'I am a dummy example with two parts'
218s             >>> x = 10
218s             >>> print(s)
218s             I am a dummy example with two parts
218s             >>> s = 'My purpose it so demonstrate how wants work here'
218s             >>> print('The new want applies ONLY to stdout')
218s             >>> print('given before the last want')
218s             >>> '''
218s                 this wont hurt the test at all
218s                 even though its multiline '''
218s             >>> y = 20
218s             The new want applies ONLY to stdout
218s             given before the last want
218s >>> # Parts from previous examples are executed in the same context
218s             >>> print(x + y)
218s             30
218s
218s this is simply text, and doesnt apply to the previous doctest the
218s             <BLANKLINE> directive is still in effect.
218s
218s         Example:
218s             >>> from xdoctest.parser import *  # NOQA
218s             >>> from xdoctest import parser
218s             >>> from xdoctest.docstr import docscrape_google
218s             >>> from xdoctest import core
218s             >>> self = parser.DoctestParser()
218s             >>> docstr = self.parse.__doc__
218s >>> blocks = docscrape_google.split_google_docblocks(docstr)
218s             >>> doclineno = self.parse.__func__.__code__.co_firstlineno
218s             >>> key, (string, offset) = blocks[-2]
218s             >>> self._label_docsrc_lines(string)
218s             >>> doctest_parts = self.parse(string)
218s >>> # each part with a want-string needs to be broken in two
218s             >>> assert len(doctest_parts) == 6
218s             >>> len(doctest_parts)
218s         """
218s         if global_state.DEBUG_PARSER > 1:
218s             print('\n===== PARSE ====')
218s         if sys.version_info.major == 2:  # nocover
218s             string = utils.ensure_unicode(string)
218s
218s         if not isinstance(string, six.string_types):
218s raise TypeError('Expected string but got {!r}'.format(string))
218s
218s         string = string.expandtabs()
218s         # If all lines begin with the same indentation, then strip it.
218s         min_indent = _min_indentation(string)
218s         if min_indent > 0:
218s string = '\n'.join([ln[min_indent:] for ln in string.splitlines()])
218s
218s         labeled_lines = None
218s         grouped_lines = None
218s         all_parts = None
218s         try:
218s >           labeled_lines = self._label_docsrc_lines(string)
218s
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:170:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:836: in _label_docsrc_lines 218s for part, norm_line in _complete_source(line, state_indent, line_iter): 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:918: in _complete_source 218s while not static.is_balanced_statement(source_parts, only_tokens=True): 218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:941: in is_balanced_statement
218s     for t in tokenize.generate_tokens(_readline):
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s source = <function is_balanced_statement.<locals>._readline at 0x7f318114c9a0>
218s encoding = None, extra_tokens = True
218s
218s def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False): 218s """Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
218s         if encoding is None:
218s it = _tokenize.TokenizerIter(source, extra_tokens=extra_tokens)
218s         else:
218s it = _tokenize.TokenizerIter(source, encoding=encoding, extra_tokens=extra_tokens)
218s         try:
218s             for info in it:
218s                 yield TokenInfo._make(info)
218s         except SyntaxError as e:
218s             if type(e) != SyntaxError:
218s                 raise e from None
218s             msg = _transform_msg(e.msg)
218s >           raise TokenError(msg, (e.lineno, e.offset)) from None
218s E tokenize.TokenError: ('unexpected EOF in multi-line statement', (1, 0))
218s
218s /usr/lib/python3.12/tokenize.py:543: TokenError
218s
218s During handling of the above exception, another exception occurred:
218s
218s     def test_inline_directive():
218s         """
218s python ~/code/xdoctest/tests/test_parser.py test_inline_directive
218s         """
218s         string = utils.codeblock(
218s             '''
218s             >>> # doctest: +SKIP
218s             >>> func1(*
218s             >>>    [i for i in range(10)])
218s             >>> # not a directive
218s             >>> func2(  # not a directive
218s             >>>    a=b
218s             >>>    )
218s             >>> func3()  # xdoctest: +SKIP
218s             >>> func4()
218s             want1
218s             >>> func5()  # xdoctest: +SKIP
218s             want1
218s             >>> # xdoctest: +SKIP
218s             >>> func6()
218s             >>> func7(a=b,
218s             >>>            c=d) # xdoctest: +SKIP
218s             >>> # xdoctest: +SKIP
218s             >>> func8(' # doctest: not a directive')
218s             >>> func9("""
218s                       # doctest: still not a directive
218s                       """)
218s             finalwant
218s             ''')
218s         # source_lines = string.splitlines()
218s         self = parser.DoctestParser()
218s         # [0, 1, 3, 4, 7, 8, 10, 11, 12]
218s         # assert ps1_linenos == [0, 2, 5, 6, 8, 9, 10]
218s >       parts = self.parse(string)
218s
218s tests/test_parser.py:538:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s self = <xdoctest.parser.DoctestParser object at 0x7f318199e690>
218s string = '>>> # doctest: +SKIP\n>>> func1(*\n>>> [i for i in range(10)])\n>>> # not a directive\n>>> func2( # not a directi...\' # doctest: not a directive\')\n>>> func9("""\n # doctest: still not a directive\n """)\nfinalwant'
218s info = None
218s
218s     def parse(self, string, info=None):
218s         """
218s         Divide the given string into examples and interleaving text.
218s
218s         Args:
218s             string (str): string representing the doctest
218s info (dict | None): info about where the string came from in case of an
218s                 error
218s
218s         Returns:
218s             List[xdoctest.doctest_part.DoctestPart]:
218s                 a list of `DoctestPart` objects
218s
218s         CommandLine:
218s             python -m xdoctest.parser DoctestParser.parse
218s
218s         Example:
218s             >>> s = 'I am a dummy example with two parts'
218s             >>> x = 10
218s             >>> print(s)
218s             I am a dummy example with two parts
218s             >>> s = 'My purpose it so demonstrate how wants work here'
218s             >>> print('The new want applies ONLY to stdout')
218s             >>> print('given before the last want')
218s             >>> '''
218s                 this wont hurt the test at all
218s                 even though its multiline '''
218s             >>> y = 20
218s             The new want applies ONLY to stdout
218s             given before the last want
218s >>> # Parts from previous examples are executed in the same context
218s             >>> print(x + y)
218s             30
218s
218s this is simply text, and doesnt apply to the previous doctest the
218s             <BLANKLINE> directive is still in effect.
218s
218s         Example:
218s             >>> from xdoctest.parser import *  # NOQA
218s             >>> from xdoctest import parser
218s             >>> from xdoctest.docstr import docscrape_google
218s             >>> from xdoctest import core
218s             >>> self = parser.DoctestParser()
218s             >>> docstr = self.parse.__doc__
218s >>> blocks = docscrape_google.split_google_docblocks(docstr)
218s             >>> doclineno = self.parse.__func__.__code__.co_firstlineno
218s             >>> key, (string, offset) = blocks[-2]
218s             >>> self._label_docsrc_lines(string)
218s             >>> doctest_parts = self.parse(string)
218s >>> # each part with a want-string needs to be broken in two
218s             >>> assert len(doctest_parts) == 6
218s             >>> len(doctest_parts)
218s         """
218s         if global_state.DEBUG_PARSER > 1:
218s             print('\n===== PARSE ====')
218s         if sys.version_info.major == 2:  # nocover
218s             string = utils.ensure_unicode(string)
218s
218s         if not isinstance(string, six.string_types):
218s raise TypeError('Expected string but got {!r}'.format(string))
218s
218s         string = string.expandtabs()
218s         # If all lines begin with the same indentation, then strip it.
218s         min_indent = _min_indentation(string)
218s         if min_indent > 0:
218s string = '\n'.join([ln[min_indent:] for ln in string.splitlines()])
218s
218s         labeled_lines = None
218s         grouped_lines = None
218s         all_parts = None
218s         try:
218s             labeled_lines = self._label_docsrc_lines(string)
218s             grouped_lines = self._group_labeled_lines(labeled_lines)
218s             all_parts = list(self._package_groups(grouped_lines))
218s         except Exception as orig_ex:
218s
218s             if labeled_lines is None:
218s                 failpoint = '_label_docsrc_lines'
218s             elif grouped_lines is None:
218s                 failpoint = '_group_labeled_lines'
218s             elif all_parts is None:
218s                 failpoint = '_package_groups'
218s             if global_state.DEBUG_PARSER:
218s                 print('<FAILPOINT>')
218s                 print('!!! FAILED !!!')
218s                 print('failpoint = {!r}'.format(failpoint))
218s
218s                 import ubelt as ub
218s                 import traceback
218s                 tb_text = traceback.format_exc()
218s                 tb_text = ub.highlight_code(tb_text)
218s                 tb_text = ub.indent(tb_text)
218s                 print(tb_text)
218s
218s print('Failed to parse string = <{[<{[<{[ # xdoc debug')
218s                 print(string)
218s                 print(']}>]}>]}>  # xdoc debug end string')
218s
218s                 print('info = {}'.format(ub.repr2(info)))
218s                 print('-----')
218s                 print('orig_ex = {}'.format(orig_ex))
218s print('labeled_lines = {}'.format(ub.repr2(labeled_lines))) 218s print('grouped_lines = {}'.format(ub.repr2(grouped_lines, nl=3)))
218s                 print('all_parts = {}'.format(ub.repr2(all_parts)))
218s                 print('</FAILPOINT>')
218s                 # sys.exit(1)
218s >           raise exceptions.DoctestParseError(
218s                 'Failed to parse doctest in {}'.format(failpoint),
218s                 string=string, info=info, orig_ex=orig_ex)
218s E xdoctest.exceptions.DoctestParseError: Failed to parse doctest in _label_docsrc_lines
218s
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:205: DoctestParseError 218s _______________________ test_gh_issue_25_parsing_failure _______________________
218s
218s     def test_gh_issue_25_parsing_failure():
218s         string = utils.codeblock(
218s             '''
218s             >>> _, o = 0, 1
218s             >>> A = B = C = D = 1
218s             >>> cc_mask = [        # Y
218s             >>>     [ _, _, _, o, _, _, ],  # 0
218s             >>>     [ _, _, o, o, o, _, ],  # 1
218s             >>>     [ _, o, o, o, o, o, ],  # 2
218s             >>>     [ o, o, o, o, o, _, ],  # 3
218s             >>>     [ _, o, o, o, _, _, ],  # 4
218s             >>>     [ _, _, o, o, _, _, ],  # 5
218s             >>> # X:  0  1  2  3  4  5  6
218s             >>> ]
218s             >>> # a regular comment
218s             >>> print(cc_mask)
218s             ''')
218s         source_lines = string.splitlines()
218s         self = parser.DoctestParser()
218s >       ps1_linenos = self._locate_ps1_linenos(source_lines)[0]
218s
218s tests/test_parser.py:719:
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:555: in _locate_ps1_linenos 218s exec_source_lines = list(_hack_comment_statements(exec_source_lines)) 218s /usr/lib/python3/dist-packages/xdoctest/parser.py:545: in _hack_comment_statements
218s     intervals = balanced_intervals(lines)
218s /usr/lib/python3/dist-packages/xdoctest/parser.py:533: in balanced_intervals 218s while not static.is_balanced_statement(lines[a:b], only_tokens=True) and a >= 0: 218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:941: in is_balanced_statement
218s     for t in tokenize.generate_tokens(_readline):
218s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
218s
218s source = <function is_balanced_statement.<locals>._readline at 0x7f318114c7c0>
218s encoding = None, extra_tokens = True
218s
218s def _generate_tokens_from_c_tokenizer(source, encoding=None, extra_tokens=False): 218s """Tokenize a source reading Python code as unicode strings using the internal C tokenizer"""
218s         if encoding is None:
218s it = _tokenize.TokenizerIter(source, extra_tokens=extra_tokens)
218s         else:
218s it = _tokenize.TokenizerIter(source, encoding=encoding, extra_tokens=extra_tokens)
218s         try:
218s             for info in it:
218s                 yield TokenInfo._make(info)
218s         except SyntaxError as e:
218s             if type(e) != SyntaxError:
218s                 raise e from None
218s             msg = _transform_msg(e.msg)
218s >           raise TokenError(msg, (e.lineno, e.offset)) from None
218s E tokenize.TokenError: ('unexpected EOF in multi-line statement', (1, 0))
218s
218s /usr/lib/python3.12/tokenize.py:543: TokenError
218s __________________ TestXDoctest.test_xdoctest_multiline_list ___________________
218s
218s self = <test_plugin.TestXDoctest object at 0x7f3181bdd040>
218s testdir = <Testdir local('/tmp/pytest-of-ubuntu/pytest-0/test_xdoctest_multiline_list0')>
218s
218s     def test_xdoctest_multiline_list(self, testdir):
218s         """
218s         pytest tests/test_plugin.py -k test_xdoctest_multiline_list
218s         """
218s         p = testdir.maketxtfile(test_xdoctest_multiline_string="""
218s             .. xdoctest::
218s
218s                 >>> x = [1, 2, 3,
218s                 >>>      4, 5, 6]
218s                 >>> print(len(x))
218s                 6
218s         """)
218s result = testdir.runpytest(p, "--xdoctest-modules", *EXTRA_ARGS)
218s >       result.stdout.fnmatch_lines(['* 1 passed*'])
218s E       Failed: nomatch: '* 1 passed*'
218s E and: '============================= test session starts ==============================' 218s E and: 'platform linux -- Python 3.12.0+, pytest-7.4.3, pluggy-1.3.0' 218s E and: 'rootdir: /tmp/pytest-of-ubuntu/pytest-0/test_xdoctest_multiline_list0'
218s E           and: 'plugins: xdoctest-1.1.1'
218s E           and: 'collected 0 items'
218s E           and: ''
218s E and: '=============================== warnings summary ===============================' 218s E and: '../../../../usr/lib/python3/dist-packages/xdoctest/core.py:426' 218s E and: ' /usr/lib/python3/dist-packages/xdoctest/core.py:426: UserWarning: Cannot scrape callname=test_xdoctest_multiline_string.txt in modpath=None line=1.' 218s E and: " Caused by: DoctestParseError('Failed to parse doctest in _label_docsrc_lines')"
218s E           and: '  .. xdoctest::'
218s E           and: '  '
218s E           and: '      >>> x = [1, 2, 3,'
218s E           and: '      >>>      4, 5, 6]'
218s E           and: '      >>> print(len(x))'
218s E           and: '      6'
218s E and: " Original Error: TokenError('unexpected EOF in multi-line statement', (1, 0))"
218s E           and: '  '
218s E           and: '    warnings.warn(msg)'
218s E           and: ''
218s E and: '-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html' 218s E and: '============================== 1 warning in 0.00s =============================='
218s E       remains unmatched: '* 1 passed*'
218s
218s /tmp/autopkgtest.XJHLC7/autopkgtest_tmp/tests/test_plugin.py:792: Failed 218s ----------------------------- Captured stdout call ----------------------------- 218s ============================= test session starts ==============================
218s platform linux -- Python 3.12.0+, pytest-7.4.3, pluggy-1.3.0
218s rootdir: /tmp/pytest-of-ubuntu/pytest-0/test_xdoctest_multiline_list0
218s plugins: xdoctest-1.1.1
218s collected 0 items
218s
218s =============================== warnings summary ===============================
218s ../../../../usr/lib/python3/dist-packages/xdoctest/core.py:426
218s /usr/lib/python3/dist-packages/xdoctest/core.py:426: UserWarning: Cannot scrape callname=test_xdoctest_multiline_string.txt in modpath=None line=1. 218s Caused by: DoctestParseError('Failed to parse doctest in _label_docsrc_lines')
218s   .. xdoctest::
218s
218s       >>> x = [1, 2, 3,
218s       >>>      4, 5, 6]
218s       >>> print(len(x))
218s       6
218s Original Error: TokenError('unexpected EOF in multi-line statement', (1, 0))
218s
218s     warnings.warn(msg)
218s
218s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
218s ============================== 1 warning in 0.00s ============================== 218s ___________________________ test_fail_inside_twofunc ___________________________
218s
218s     def test_fail_inside_twofunc():
218s         """
218s python ~/code/xdoctest/tests/test_traceback.py test_fail_inside_twofunc
218s
218s         """
218s         import warnings
218s         with warnings.catch_warnings():
218s             warnings.simplefilter("ignore")
218s             text = _run_case(utils.codeblock(
218s                 '''
218s                 def func(a):
218s                     """
218s                     Example:
218s                         >>> print('not failed')
218s                         >>> # just a comment
218s                         >>> print(("foo"
218s                         ...        "bar"))
218s                         >>> a = []()
218s                         >>> func(a)
218s                     """
218s                     return a
218s
218s                 def func2(a):
218s                     """
218s                     Example:
218s                         >>> pass
218s                     """
218s                     pass
218s                 '''))
218s             assert text
218s             assert '>>> a = []()' in text
218s >           assert 'rel: 5, abs: 8' in text
218s E assert 'rel: 5, abs: 8' in "Start doctest_module('/tmp/tmp_bp22aaj/test_linenos_504ceecc.py')\nListing tests\nmsg = Cannot scrape callname=func i...tmp_bp22aaj/test_linenos_504ceecc.py::func2:0\n====== </exec> ======\n============\n=== 1 passed in 0.00 seconds ===\n"
218s
218s tests/test_traceback.py:90: AssertionError
218s ----------------------------- Captured stdout call -----------------------------
218s 
218s
218s
218s  <RUN CASE>
218s   ========
218s 
218s CASE SOURCE:
218s ------------
218s      1 def func(a):
218s      2     """
218s      3     Example:
218s      4         >>> print('not failed')
218s      5         >>> # just a comment
218s      6         >>> print(("foo"
218s      7         ...        "bar"))
218s      8         >>> a = []()
218s      9         >>> func(a)
218s     10     """
218s     11     return a
218s     12 
218s     13 def func2(a):
218s     14     """
218s     15     Example:
218s     16         >>> pass
218s     17     """
218s     18     pass
218s
218s Start doctest_module('/tmp/tmp_bp22aaj/test_linenos_504ceecc.py')
218s Listing tests
218s msg = Cannot scrape callname=func in modpath=/tmp/tmp_bp22aaj/test_linenos_504ceecc.py line=2. 218s Caused by: DoctestParseError('Failed to parse doctest in _label_docsrc_lines')
218s
218s Example:
218s     >>> print('not failed')
218s     >>> # just a comment
218s     >>> print(("foo"
218s     ...        "bar"))
218s     >>> a = []()
218s     >>> func(a)
218s
218s Original Error: TokenError('unexpected EOF in multi-line statement', (1, 0))
218s
218s gathering tests
218s running 1 test(s)
218s ====== <exec> ======
218s * DOCTEST : /tmp/tmp_bp22aaj/test_linenos_504ceecc.py::func2:0, line 16 <- wrt source file
218s DOCTEST SOURCE
218s 1 >>> pass
218s DOCTEST STDOUT/STDERR
218s DOCTEST RESULT
218s * SUCCESS: /tmp/tmp_bp22aaj/test_linenos_504ceecc.py::func2:0
218s ====== </exec> ======
218s ============
218s === 1 passed in 0.00 seconds ===
218s 
218s
218s  --- </END RUN CASE> ---
218s
218s 
218s ___________________________ test_fail_inside_onefunc ___________________________
218s
218s     def test_fail_inside_onefunc():
218s         """
218s python ~/code/xdoctest/tests/test_traceback.py test_fail_inside_onefunc
218s
218s         """
218s         text = _run_case(utils.codeblock(
218s             '''
218s             def func(a):
218s                 """
218s                 Example:
218s                     >>> x = 1
218s                     >>> # just a comment
218s                     >>> print(("foo"
218s                     ...        "bar"))
218s                     foobar
218s                     >>> a = []()
218s                     >>> func(a)
218s                 """
218s                 return a
218s             '''))
218s         assert text
218s         assert '>>> a = []()' in text
218s >       assert 'rel: 6, abs: 9,' in text
218s E assert 'rel: 6, abs: 9,' in "Start doctest_module('/tmp/tmph961i27x/test_linenos_9e94cb98.py')\nListing tests\nmsg = Cannot scrape callname=func i...cted EOF in multi-line statement', (1, 0))\n \n warnings.warn(msg)\n \n=== 2 warnings in 0.00 seconds ===\n"
218s
218s tests/test_traceback.py:115: AssertionError
218s ----------------------------- Captured stdout call -----------------------------
218s 
218s
218s
218s  <RUN CASE>
218s   ========
218s 
218s CASE SOURCE:
218s ------------
218s      1 def func(a):
218s      2     """
218s      3     Example:
218s      4         >>> x = 1
218s      5         >>> # just a comment
218s      6         >>> print(("foo"
218s      7         ...        "bar"))
218s      8         foobar
218s      9         >>> a = []()
218s     10         >>> func(a)
218s     11     """
218s     12     return a
218s
218s Start doctest_module('/tmp/tmph961i27x/test_linenos_9e94cb98.py')
218s Listing tests
218s msg = Cannot scrape callname=func in modpath=/tmp/tmph961i27x/test_linenos_9e94cb98.py line=2. 218s Caused by: DoctestParseError('Failed to parse doctest in _label_docsrc_lines')
218s
218s Example:
218s     >>> x = 1
218s     >>> # just a comment
218s     >>> print(("foo"
218s     ...        "bar"))
218s     foobar
218s     >>> a = []()
218s     >>> func(a)
218s
218s Original Error: TokenError('unexpected EOF in multi-line statement', (1, 0))
218s
218s gathering tests
218s running 0 test(s)
218s ============
218s
218s === Found 2 parse-time warnings ===
218s --- Parse Warning: 1 / 2 ---
218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s       docstr = utils.ensure_unicode(docnode.value.s)
218s
218s --- Parse Warning: 2 / 2 ---
218s /usr/lib/python3/dist-packages/xdoctest/core.py:426: UserWarning: Cannot scrape callname=func in modpath=/tmp/tmph961i27x/test_linenos_9e94cb98.py line=2. 218s Caused by: DoctestParseError('Failed to parse doctest in _label_docsrc_lines')
218s
218s     Example:
218s         >>> x = 1
218s         >>> # just a comment
218s         >>> print(("foo"
218s         ...        "bar"))
218s         foobar
218s         >>> a = []()
218s         >>> func(a)
218s
218s Original Error: TokenError('unexpected EOF in multi-line statement', (1, 0))
218s
218s       warnings.warn(msg)
218s
218s === 2 warnings in 0.00 seconds ===
218s 
218s
218s  --- </END RUN CASE> ---
218s
218s 
218s =============================== warnings summary =============================== 218s ../../../usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: 147 warnings
218s tests/test_cases.py: 2 warnings
218s tests/test_core.py: 14 warnings
218s tests/test_errors.py: 2 warnings
218s tests/test_static.py: 12 warnings
218s tests/test_traceback.py: 1 warning
218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:375: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s     docstr = utils.ensure_unicode(docnode.value.s)
218s
218s ../../../usr/lib/python3/dist-packages/xdoctest/static_analysis.py:270: 11 warnings 218s /usr/lib/python3/dist-packages/xdoctest/static_analysis.py:270: DeprecationWarning: Attribute s is deprecated and will be removed in Python 3.14; use value instead
218s     node.test.comparators[0].s == '__main__',
218s
218s tests/test_runner.py::test_dump
218s tests/test_runner.py::test_dump
218s tests/test_runner.py::test_dump
218s tests/test_runner.py::test_dump
218s tests/test_runner.py::test_dump
218s tests/test_runner.py::test_dump
218s tests/test_runner.py::test_dump
218s /usr/lib/python3/dist-packages/pyflakes/checker.py:1338: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
218s     return isinstance(node, ast.Str) or (isinstance(node, ast.Expr) and
218s
218s tests/test_runner.py::test_dump
218s tests/test_runner.py::test_dump
218s /usr/lib/python3/dist-packages/pyflakes/checker.py:1339: DeprecationWarning: ast.Str is deprecated and will be removed in Python 3.14; use ast.Constant instead
218s     isinstance(node.value, ast.Str))
218s
218s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
218s =========================== short test summary info ============================ 218s FAILED tests/test_core.py::test_indented_grouping - xdoctest.exceptions.Docte... 218s FAILED tests/test_doctest_example.py::test_multiline_list - xdoctest.exceptio... 218s FAILED tests/test_errors.py::test_runner_syntax_error - AssertionError: asser... 218s FAILED tests/test_parser.py::test_label_indented_lines - tokenize.TokenError:... 218s FAILED tests/test_parser.py::test_ps1_linenos_4 - tokenize.TokenError: ('unex... 218s FAILED tests/test_parser.py::test_nonbalanced_statement - AttributeError: 'To... 218s FAILED tests/test_parser.py::test_bad_indent - AttributeError: 'TokenError' o... 218s FAILED tests/test_parser.py::test_inline_directive - xdoctest.exceptions.Doct... 218s FAILED tests/test_parser.py::test_gh_issue_25_parsing_failure - tokenize.Toke... 218s FAILED tests/test_plugin.py::TestXDoctest::test_xdoctest_multiline_list - Fai... 218s FAILED tests/test_traceback.py::test_fail_inside_twofunc - assert 'rel: 5, ab... 218s FAILED tests/test_traceback.py::test_fail_inside_onefunc - assert 'rel: 6, ab... 218s =========== 12 failed, 195 passed, 19 skipped, 198 warnings in 8.08s ===========

Reply via email to