I'm experiencing a lost traceback from a doctest when running them under Pytest. It's reversible state library that changes state in a reversible manner, e.g this example code:
import sys
from altered import state, forget
with state(sys.modules, shutil=forget):
import shutil
# Traceback output....
should simulate an import problem and crash. If I run it as a script in my project root directory I do get a traceback:
Traceback (most recent call last):
...traceback details...
KeyError: 'shutil'
On the other hand, I have a documentation file with doctest-formatted examples in it with the following example:
>>> import sys
>>> from altered import state, forget
>>> with state(sys.modules, shutil=forget):
... import shutil
Traceback (most recent call last):
...
KeyError: 'shutil'
If I add the example file as a doctested glob to pytest, pytest complains when running it:
$ py.test docs/examples.rst
============================ test session starts =============================
platform darwin -- Python 2.7.10, pytest-3.0.5, py-1.4.30, pluggy-0.4.0
rootdir: /Users/jacob/src/oss/altered.states, inifile: pytest.ini
collected 1 items
docs/examples.rst F
================================== FAILURES ==================================
[ ... parts of documentation /w doctest ... ]
053
054 >>> import sys
055 >>> from altered import state, forget
056 >>> with state(sys.modules, shutil=forget):
Expected:
Traceback (most recent call last):
...
KeyError: 'shutil'
Got nothing
Could it be pytest's stdout capturing that's causing trouble? Or do anyone see any other obvious entry point for troubleshooting?
I have tried to put breakpoints in the doctest examples of my doc file but stepping takes me in and out of pdb itself and I haven't been able to make any sense of the problem using that approach.