python - 如何使用 pytest 夹具传递字典
问题描述
以下代码给出错误“TypeError:'function'对象不可下标。
import pytest
@pytest.fixture
def get_data():
data = {'name': 'Bill', 'age': 20}
return data
def test_get_data(get_data):
test_data = get_data
assert test_data['name'] == 'Bill'
assert test_data['age'] == 20
test_get_data(get_data)
解决方案
推荐阅读
- mysql - 从列而不是主键中选择最大值的正确方法是什么
- javascript - 通过 props 设置 2 个 classNames
- c++ - 编译后 CMake 共享 dll 不起作用
- android - Soti Surf 作为 Okta Android SDK 支持的浏览器
- php - 尝试将 api 与 react native 连接
- javascript - 向下推元素以填充剩余的垂直空间
- html - 绑定到 class 和 id 时,悬停不起作用
- javascript - 尝试使用 javascript 上的 if 语句创建年龄限制
- google-analytics - 为什么我的 Google Analytics API 查询恰好返回 1.000.000 行?
- python - 如何将 pandas df 转换为复杂的 json 结构?