yag*_*ger 16 python pytest pudb
之前我选择的测试库是单元测试.它正在使用我最喜欢的调试器--Pudb.不是Pdb !!!
要将Pudb与unittest 一起使用,我会import pudb;pudb.set_trace()在代码行之间粘贴.然后我执行了python -m unittest my_file_test,其中my_file_test是my_file_test.py文件的模块表示.
简单地使用nosetests my_file_test.py将无法工作 - AttributeError: StringIO instance has no attribute 'fileno'将被抛出.
随着py.test既不作品:
py.test my_file_test.py
也不
python -m pytest my_file_test.py
两个扔 ValueError: redirected Stdin is pseudofile, has no fileno()
有关如何使用任何想法Pudb与py.test
yag*_*ger 16
只需添加-s标志就不会替换stdin和stdout,并且可以访问调试,即pytest -s my_file_test.py可以解决问题.
在ambi提供的文档中,也可以说以前使用显式的-s也是常规pdb所必需的,现在-s标志与--pdb标志一起隐式使用.
但是py.test不会隐式支持pUdb,因此需要设置-s.
| 归档时间: |
|
| 查看次数: |
2739 次 |
| 最近记录: |