pytest print stacktrace when import fails
<p>Suppose a python test module generates an <code>ImportError</code>. <code>pytest</code> (version 3.0.2) generates a compact error report:</p>

<pre><code>__________________________________________ ERROR collecting tests/wc_tests/log/test_logger.py __________________________________________
ImportError while importing test module '/Users/arthur_at_sinai/gitOnMyLaptopLocal/Mpn-Example/tests/wc_tests/log/test_logger.py'.
Original error message:
'No module named 'wc.config.core''
Make sure your test modules/packages have valid Python names.
</code></pre>

<p>In contrast, <code>nosetests-3.4</code> generates a stacktrace, like this:</p>

<pre><code>ERROR: Failure: ImportError (No module named 'wc.config.core')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/nose/importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 234, in load_module
    return load_source(name, filename, file)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 172, in load_source
    module = _load(spec)
  File "&lt;frozen importlib._bootstrap&gt;", line 693, in _load
  File "&lt;frozen importlib._bootstrap&gt;", line 673, in _load_unlocked
  File "&lt;frozen importlib._bootstrap_external&gt;", line 665, in exec_module
  File "&lt;frozen importlib._bootstrap&gt;", line 222, in _call_with_frames_removed
  File "/Users/arthur_at_sinai/gitOnMyLaptopLocal/Mpn-Example/tests/wc_tests/log/test_logger.py", line 12, in &lt;module&gt;
    from wc.sim.core import Simulator
  File "/Users/arthur_at_sinai/gitOnMyLaptopLocal/Mpn-Example/wc/sim/core.py", line 16, in &lt;module&gt;
    from wc.log.checkpoint import CheckpointLogger
  File "/Users/arthur_at_sinai/gitOnMyLaptopLocal/Mpn-Example/wc/log/checkpoint.py", line 9, in &lt;module&gt;
    from wc.config.core import config
ImportError: No module named 'wc.config.core'
</code></pre>

<p>How can one get <code>pytest</code> to produce similar stacktrace information? These options are available</p>

<pre><code>-l, --showlocals      show locals in tracebacks (disabled by default).
--tb=style            traceback print mode (auto/long/short/line/native/no).
--full-trace          don't cut any tracebacks (default is to cut).
</code></pre>

<p>but none of them make a tb for me. Nor does <code>pytest -vv</code>.</p>

<p>Thanks</p>

<p>Arthur</p>

<p>This was <a href="https://github.com/pytest-dev/pytest/pull/1979" rel="nofollow">changed</a> in pytest a week ago to display the full traceback.</p>

<p>If you don't want to wait for the next release, you could use pytest from the git repository via <code>pip install git+https://github.com/pytest-dev/pytest.git</code> in the meantime.</p>

python py.test