假设python测试模块生成ImportError
。 pytest
(版本3.0.2)生成紧凑错误报告:
__________________________________________ 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.
相反,nosetests-3.4
会生成一个堆栈跟踪,如下所示:
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 "<frozen importlib._bootstrap>", line 693, in _load
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", 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 <module>
from wc.sim.core import Simulator
File "/Users/arthur_at_sinai/gitOnMyLaptopLocal/Mpn-Example/wc/sim/core.py", line 16, in <module>
from wc.log.checkpoint import CheckpointLogger
File "/Users/arthur_at_sinai/gitOnMyLaptopLocal/Mpn-Example/wc/log/checkpoint.py", line 9, in <module>
from wc.config.core import config
ImportError: No module named 'wc.config.core'
如何让pytest
生成类似的堆栈跟踪信息?这些选项可用
-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).
但他们都没有为我做出任何决定。 pytest -vv
也没有。
由于
亚瑟
答案 0 :(得分:4)
一周前在pytest中changed显示完整的追溯。
如果您不想等待下一个版本,可以在此期间通过block,setvar:tx.anomaly_score=+%{tx.critical_anomaly_score}
使用git存储库中的pytest。