在我选择的测试库之前unittest。它与我最喜欢的调试器 - PuDB 一起工作。不是PDB!!!
使用 PuDB 与unittest,我粘贴import pudb;pudb.set_trace()
代码行之间。
然后我执行了python -m unittest my_file_test
, where 我的文件测试是模块表示my_file_test.py file.
只需使用nosetests my_file_test.py
行不通 -AttributeError: StringIO instance has no attribute 'fileno'
会被抛出。
With py.test两者都不起作用:
py.test my_file_test.py
nor
python -m pytest my_file_test.py
两者都抛出
ValueError:重定向的 Stdin 是伪文件,没有 fileno()
我该如何使用Pudb with py.test?
只需添加-s标志,pytest不会替换标准输入 https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin) and 标准输出 https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29并且可以进行调试,即pytest -s my_file_test.py
会成功的。
在ambi提供的文档中,还说以前使用-s明确要求定期pdb也是如此,但现在-s标志隐式地与--pdb flag.
然而,pytest不隐式支持PuDB,所以需要设置-s。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)