字典的pytest夹具产量列表“ yield_fixture函数具有多个'yield':”

问题描述 投票:0回答:1

我已经定义了一个固定装置,如:

    @pytest.fixture
    def mock_yield_data(self):
        for data in [
            {
                1: 2, 2: 3
            },
            {
                2: 4, 4: 5
            },
        ]:
            yield data

和类似的测试方法:

    def test_fixture(self, mock_yield_data):
        for data in mock_yield_data:
            assert data

断言成功,但是teardown抛出yield_fixture function has more than one 'yield':

==================================================================================================== ERRORS ====================================================================================================
_________________________________________________________________________ ERROR at teardown of TestClass.test_fixture _________________________________________________________________________
yield_fixture function has more than one 'yield':
python pytest fixtures
1个回答
1
投票
© www.soinside.com 2019 - 2024. All rights reserved.