[New-bugs-announce] [issue45249] Fine grained error locations do not work in doctests

Andrei Kulakov report at bugs.python.org
Mon Sep 20 12:30:58 EDT 2021


New submission from Andrei Kulakov <andrei.avk at gmail.com>:

It seems like fine grained error locations do not work in failed doctest traceback output:

version 3.11.0a0

file contents:
------------------
def a(x):
    """
    >>> 1 1
    1
    """
import doctest
doctest.testmod()

OUTPUT
-------

Failed example:
    1 1
Exception raised:
    Traceback (most recent call last):
      File "/Users/ak/opensource/cpython/Lib/doctest.py", line 1348, in __run
        exec(compile(example.source, filename, "single",
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<doctest __main__.a[0]>", line 1
        1 1
        ^
    SyntaxError: invalid syntax. Perhaps you forgot a comma?


The location in doctests that causes this:

https://github.com/python/cpython/blob/5846c9b71ee9277fe866b1bdee4cc6702323fe7e/Lib/doctest.py#L1348

----------
components: Interpreter Core, Tests
messages: 402257
nosy: andrei.avk, kj, pablogsal
priority: low
severity: normal
status: open
title: Fine grained error locations do not work in doctests
type: behavior
versions: Python 3.11

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45249>
_______________________________________


More information about the New-bugs-announce mailing list