【发布时间】:2017-07-23 16:40:25
【问题描述】:
我正在寻找诸如 ruby rspec 的 focus 元数据或 elixir 的混合标签之类的东西来运行单个 python 测试。
Ruby RSpec 示例:
# $ rspec spec
it 'runs a single test', :focus do
expect(2).to eq(2)
end
Elixir ExUnit & Mix 示例:
# $ mix test --only focus
@tag :focus
test "only run this test" do
assert true
end
这是否可能/适用于任何 python 测试运行器和夹具组合?通过命令行参数指定嵌套的module.class.test_name 来运行单个测试在大型项目中可能会变得非常冗长。
有点像:
所需的 Python 代码:
# $ nosetests --only focus
from tests.fixtures import focus
class TestSomething(unittest.TestCase):
@focus
def test_all_the_things(self):
self.assertEqual(1, 1)
【问题讨论】:
标签: python unit-testing pytest nose