我无法理解为什么下面对 DynamoDB 表的查询不起作用:
dict_table.query(KeyConditionExpression='norm = :cihan', ExpressionAttributeValues={':cihan': {'S': 'cihan'}})
Run Code Online (Sandbox Code Playgroud)
并抛出此错误:
ClientError: An error occurred (ValidationException) when calling the Query operation: One or more parameter values were invalid: Condition parameter type does not match schema type
而以下工作:
dict_table.query(KeyConditionExpression=Key('norm').eq('cihan'))
Run Code Online (Sandbox Code Playgroud)
norm是一个字符串类型的字段。我正在使用 boto3 v 1.4.0 并遵循文档:
In [43]: boto3.__version__
Out[43]: '1.4.0'
Run Code Online (Sandbox Code Playgroud)
谁能看到第一个查询中的错误是什么?
额外的问题:所有的代币是什么以及需要一直替换它们?为什么我不能说dict_table.query(KeyConditionExpression='norm = cihan')
我想在不同的 pytest 测试文件之间共享数据和预期的失败。让我举个例子吧。我正在测试 test_a.py 中的 A 类和 test_b.py 中的 B 类。有趣的是,这两个类需要相互兼容,所以我想在相同的数据上测试它们,并将一些数据标记为 xfail。我怎样才能做到这一点?
示例数据:
my_test_data = [
('test_data', 'expected_output'),
pytest.mark.xfail(('another_test', 'failing_output')),
]
Run Code Online (Sandbox Code Playgroud)
我可以把它放在 a 中conftest.py并从测试中导入它,但显式导入感觉不对。