我正在尝试创建不基于单元测试的测试类.
这个类下的这个方法
class ClassUnderTestTests: def test_something(self):
从命令行调用py.test或在PyCharm中运行此测试时(在它自己的模块上),无法检测并运行.
这个
def test_something(self):
可以检测并运行类外的相同方法.
我想把我的测试分组在类下,除非我遗漏了一些我正在遵循py.test规范来做到这一点.
环境:Windows 7,pyCharm,py.test设置为测试运行器.
按照惯例,它会搜索
测试前缀测试类(没有init方法)
例如.
# content of test_class.py class TestClass: def test_one(self): x = "this" assert 'h' in x def test_two(self): x = "hello" assert hasattr(x, 'check')
请参阅此处的文档