Cod*_*ice 6 python unit-testing fixtures pytest
我正在使用pytest编写一些测试,其中很多都有类似的装置.我想将这些"全局"灯具放在一个文件中,以便它们可以在多个测试文件中重复使用.我的第一个想法是创建一个fixtures.py文件,如
import pytest
@pytest.fixture()
def my_fixture():
# do something
Run Code Online (Sandbox Code Playgroud)
现在我该如何使用这个夹具my_tests.py?
def test_connect(my_fixture):
pass
Run Code Online (Sandbox Code Playgroud)
这给了fixture 'my_fixture' not found.我可以from fixtures import my_fixture.这种情况的建议解决方案是什么?
| 归档时间: |
|
| 查看次数: |
1133 次 |
| 最近记录: |