gpt4 book ai didi

python - Pytest fixture 返回倍数

转载 作者:行者123 更新时间:2023-12-03 01:09:23 25 4
gpt4 key购买 nike

是否有可能有一个返回字典和数据帧的装置?

import somefile
import pytest

@pytest.fixture()
def setup():
dictionary, dataframe = somefile.get_Di_And_Df()
return(dictionary, dataframe)

def test_check(setup):
assert dictionary['movie']['action'] == 'Avengers'
assert dataframe.shape[0] == 5

最佳答案

fixture 的返回值(或产生值)实际上是在测试执行期间作为函数参数注入(inject)的对象:

def test_check(setup):
dictionary, dataframe = setup
assert dictionary['movie']['action'] == 'Avengers'
assert dataframe.shape[0] == 5

关于python - Pytest fixture 返回倍数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52305185/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com