获得;“空套房”;在Python(V-3.8)中使用PyTest运行测试用例时出错
下面是获得;“空套房”;在Python(V-3.8)中使用PyTest运行测试用例时出错,python,python-3.x,pytest,Python,Python 3.x,Pytest,下面是conftest.py和test_1.py文件的代码。知道我为什么会出现“空套件”错误吗 conftest.py import pytest @pytest.fixture() def setup(): print("hi") yield print("end") import pytest @pytest.mark.usefixtures("setup") class Abc: def
conftest.py
和test_1.py
文件的代码。知道我为什么会出现“空套件”错误吗
import pytest
@pytest.fixture()
def setup():
print("hi")
yield
print("end")
import pytest
@pytest.mark.usefixtures("setup")
class Abc:
def test_demo(self):
print("hello")
def test_demo1(self):
print("Hey")
import pytest
@pytest.fixture()
def setup():
print("hi")
yield
print("end")
import pytest
@pytest.mark.usefixtures("setup")
class Abc:
def test_demo(self):
print("hello")
def test_demo1(self):
print("Hey")
test_1.py后
获取以下消息:
Testing started at 15:15 ...
C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\python.exe "C:\Program Files\PyCharm\PyCharm Community Edition 2020.2\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py" --path C:/Users/Lenovo/PycharmProjects/pythonProject1/famework-pytest/test_1.py
Launching pytest with arguments C:/Users/Lenovo/PycharmProjects/pythonProject1/famework-pytest/test_1.py in C:\Users\Lenovo\PycharmProjects\pythonProject1\famework-pytest
============================= test session starts =============================
platform win32 -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- C:\Users\Lenovo\AppData\Local\Programs\Python\Python38-32\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\Lenovo\PycharmProjects\pythonProject1\famework-pytest
collecting ... collected 0 items
============================ no tests ran in 0.01s ============================
Process finished with exit code 5
Empty suite
将
Abc
重命名为TestAbc
,请参见是,它现在正在@hoefling工作。这是PyTest的新标准吗?请参阅尾部链接中的注释-“测试前缀测试类中的测试前缀测试函数或方法(不带init方法)。”