使用 Tavern 并尝试针对此 yaml 运行 tavern-ci:
test_name: tavern poc
- name: list
request:
url: https://xxx.xxx.xxx.us/api/v3/institutions/
method: GET
response:
status_code: 200
headers:
content-type: application/json
save:
body:
content: content
Run Code Online (Sandbox Code Playgroud)
我收到 E ScannerError: 此处不允许映射值 E 在“/Users/xxx/xxx/xxx/test_poc.tavern.yaml”,第 3 行,第 9 列
已经尝试了这里提供的许多解决方案(其中大多数是“在冒号后加一个空格”),但没有任何乐趣。
Yamllint 给出了同样的错误......
我正在使用 tavern 运行 pytest 来进行一个小型测试 API 项目。测试失败,会给我带来一堆详细的错误以及我期望得到的响应(为什么失败)。我怎样才能让 pytest 不那么冗长?
我尝试了 pytest --tb=short、pytest -vv、pytest --tavern-beta-new-traceback ,但没有一个按预期工作,只是告诉我失败的原因。就像是:
E tavern.util.exceptions.TestFailError: Test 'Do something' failed:
- Status code was 200, expected 300
-------------------------------------------------------- Captured log call --------------------------------------------------------
base.py 41 ERROR Status code was 200, expected 300
==================================================== 1 failed in 0.38 seconds =====================================================
Run Code Online (Sandbox Code Playgroud)
也许 tavern 处理错误或 pytest 的方式有问题?