[New-bugs-announce] [issue22710] doctest exceptions include nondeterministic namespace

David Barnett report at bugs.python.org
Thu Oct 23 11:04:37 CEST 2014


New submission from David Barnett:

doctests includes special exception processing support (described in https://docs.python.org/3/library/doctest.html#what-about-exceptions), but in python3 it seems to print the fully-qualified class name even for exception classes in the same module, which makes the expected output vary between py2 and py3.

For instance, given a file spam/eggs.py with these contents:
  class Error(Exception):
      """Spam, Bacon, and Spam
  
      >>> raise Error()
      Traceback (most recent call last):
          ...
      Error
      """
running the command
  python3 -m doctest spam/eggs.py
will fail expecting "eggs.Error" instead of just "Error".

If you instead invoke it with the command
  nosetests3 --with-doctest spam/eggs.py
it will fail expecting yet another name, "spam.eggs.Error".

It may be possible to work around issues like this using ELLIPSIS, but it makes the doctests harder to read and it really seems like at least exception classes defined in the same file should be able to match by just their short class name.

----------
components: Library (Lib)
messages: 229864
nosy: mu_mind
priority: normal
severity: normal
status: open
title: doctest exceptions include nondeterministic namespace
type: behavior
versions: Python 3.2, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22710>
_______________________________________


More information about the New-bugs-announce mailing list