pytest - Pytest:日期对象不能作为参数传递给夹具
问题描述
我尝试使用以下代码片段将日期对象作为参数传递给 pytest 夹具并在夹具中拾取它:
@pytest.fixture
def getData(request):
"""Variable data query"""
date = request.param
#do some data calls (with the provided date)...
@pytest.mark.parametrize("getData", [(date.today())], indirect=["getData"])
def test_data(getData):
#do some tests with the data...
但是我收到错误消息,例如:
- TypeError: 'datetime.date' 对象不可下标 E
- ValueError:无法将字符串转换为时间戳
“请求”是否只接受字符串?是否有另一种可能将更复杂的对象(字符串除外)作为参数传递给夹具?
解决方案
推荐阅读
- node.js - Nginx:nodejs堆栈的内部错误500
- eclipse - Eclipse 将进度和错误日志编译为 android studio
- php - 无法在 yii 框架上创建第一个应用程序
- vb.net - 如何删除数据网格中的所有 SQL 行?
- python-3.x - PyYAML 使用重复键加载 YAML 1.1
- html - 选择复选框输入时,在图像上显示复选标记的最简单方法是什么?
- module - 可以注释组合的多态变体类型吗?
- django - 如何在同一个函数中返回两个httpresponse
- c - *x 与 x[0] 不同,当 x 是指向未定义维度数组的指针时
- python-2.7 - ThreadPoolExecutor 提交不立即返回