如何将测试标记为 "long" 并跳过它们?
How can I mark tests as "long" and skip them?
我通常 运行 我的测试使用 tox
调用 pytest
。此设置在许多项目中都能正常工作。然而,在某些项目中,我有一些测试需要很长时间(几分钟)。我不想每次都 运行 他们。我想装饰测试只要。
像这样:
$ tox --skip-long
和
# core modules
import unittest
class Foo(unittest.TestCase):
def test_bar(self):
...
@long
def test_long_bar(self):
...
How can I do this?
我通常 运行 我的测试使用 tox
调用 pytest
。此设置在许多项目中都能正常工作。然而,在某些项目中,我有一些测试需要很长时间(几分钟)。我不想每次都 运行 他们。我想装饰测试只要。
像这样:
$ tox --skip-long
和
# core modules
import unittest
class Foo(unittest.TestCase):
def test_bar(self):
...
@long
def test_long_bar(self):
...
How can I do this?