pytest 的正确文件夹结构和命名约定是什么?
What is the correct folder structure and naming convention for pytest?
为什么 pytest 不收集我的测试?
我的文件夹结构:
src
|-- examplemodule.py
tests
|-- test_examplemodule.py
test_examplemodule.py
的内容:
from unittest import TestCase
class TestExamplemodule(TestCase):
def run_mock_example(self):
# do stuff
运行 python3 -m pytest tests
给我 collected 0 tests
函数名称应分别以 test_
或 _test
开头或结尾。所以在你的情况下 test_run_mock_example()
为什么 pytest 不收集我的测试?
我的文件夹结构:
src
|-- examplemodule.py
tests
|-- test_examplemodule.py
test_examplemodule.py
的内容:
from unittest import TestCase
class TestExamplemodule(TestCase):
def run_mock_example(self):
# do stuff
运行 python3 -m pytest tests
给我 collected 0 tests
函数名称应分别以 test_
或 _test
开头或结尾。所以在你的情况下 test_run_mock_example()