Py.Test 使用 PyDev/Eclipse 静默跳过有错误的测试? [英] Py.Test silently skips tests with errors in them using PyDev/Eclipse?

查看:63
本文介绍了Py.Test 使用 PyDev/Eclipse 静默跳过有错误的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究使用 Py.Test 在我一直在处理的一些代码中自动进行单元测试.我发现了以下行为:当我构建的测试出现错误(否则会导致解释器停止运行)时,测试框架似乎完全忽略了测试.

I've been looking in to using Py.Test to automate unit testing in some code I've been working on. I've discovered the following behavior: when a test that I've built has an error (that would otherwise cause the interpreter to barf), the testing framework seems to silently ignore the test altogether.

我担心,随着我实施更多的测试,我会将这个测试有错误并且没有运行"误认为这个测试通过了".理想情况下,我想在 Eclipse 中点击一个按钮,如果它有语法错误,那么单元测试就会失败.除了为什么不编写没有语法错误的代码?"之外,我还缺少其他解决方案吗?

I'm worried that, as I implement more tests, I'll mistake "this test had an error and didn't run" for "this test passed". Ideally, I'd like to hit a button in Eclipse and have a unit test fail if it has a syntax error in it. Other than "Why don't you write code without syntax errors in it?", is there another solution I'm missing?

或者,有没有办法让 Py.Test 告诉您找到了哪些测试文件,以及运行了哪些测试文件?

Alternatively, is there a way to make Py.Test tell you what test files were found, and which ones were run?

设置为 PyDev 2.7.1 和 Eclipse 4.2,以及 Python 2.7.3 和 PyTest 2.3.4.

Setup is PyDev 2.7.1 and Eclipse 4.2, with Python 2.7.3 and PyTest 2.3.4.

推荐答案

我认为这个问题与我在 Preferenced -> PyDev -> PyUnit 中设置的命令行选项之一有关.我一直在使用 -n 4 运行,它将测试拆分到处理器上.这似乎抑制了语法错误.同样的选项也使调试不起作用(即,断点被跳过),事后看来这很明显.

I think the issue has to do with one of the command line options I set in Preferenced -> PyDev -> PyUnit. I had been running with -n 4, which splits the tests up over processors. This seems to have suppressed the syntax errors. The same option also made debugging not work (i.e., breakpoints were skipped) which seems pretty obvious in hindsight.

这篇关于Py.Test 使用 PyDev/Eclipse 静默跳过有错误的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆