[Python-Dev] Code coverage tool updated

Tim Peters tim.peters at gmail.com
Tue Nov 2 19:53:59 CET 2004


[Walter Dörwald]
> This doesn't help. The following assert in trace.py raises
> an AssertionError:
>    assert filename.endswith('.py')
> 
> I've added print statements to find_executable_linenos()
> and got the following:
> 
> [...]
> /home/coverage/LivingLogic/Python/PythonCodeCoverage/jobs/python/dist/src/Lib/sre_compile.py
> /home/coverage/LivingLogic/Python/PythonCodeCoverage/jobs/python/dist/src/Lib/test/__init__.py
> <doctest _threading_local[7]>
> Traceback (most recent call last):
>   File "../../../trace.py", line 790, in ?
>     main()
>   File "../../../trace.py", line 787, in main
>     results.write_results(missing, summary=summary, coverdir=coverdir)
>   File "../../../trace.py", line 301, in write_results
>     lnotab = find_executable_linenos(filename)
>   File "../../../trace.py", line 420, in find_executable_linenos
>     assert filename.endswith('.py')
> AssertionError
> 
> So what is <doctest _threading_local[7]>?

I haven't followed this thread, but can answer that question literally
<wink>:  it's code synthesized for the seventh doctest example in
Lib/_threading_local.py's module docstring.  The file name is
constructed by this line in doctest.py:

            # Use a special filename for compile(), so we can retrieve
            # the source code during interactive debugging (see
            # __patched_linecache_getlines).
            filename = '<doctest %s[%d]>' % (test.name, examplenum)


More information about the Python-Dev mailing list