我正在使用 tavern
作为我的 python 项目的测试框架。用于测试的模拟服务器在 yaml 文件中定义:
test_name: Test phonebook service
stages:
-name: Make sure we can create new contact
request:
url: http://localhost:9301/v2/contact
method: POST
response:
status_code: 200
body:
id: 1
当我运行测试时,出现此错误:
/Users/joey/.pyenv/versions/3.7.2/lib/python3.7/site-packages/yaml/scanner.py:579: in fetch_value
self.get_mark())
E yaml.scanner.ScannerError: mapping values are not allowed here
E in "/Users/joey/dev/iress/devel/phonebook-service-api/src/api/tavern-tests/test_contact.tavern.yaml", line 5, column 11
第 5 行是 request:
但我不知道这有什么问题。我不认为这是一个 tavern
问题,而它看起来更像 yaml
架构验证问题。
最佳答案
最后,我通过在 -
和 name
之间放置一个 space
来使其工作。
test_name: Test phonebook service
stages:
- name: Make sure we can create new contact
request:
url: http://localhost:9301/v2/contact
method: POST
response:
status_code: 200
body:
id: 1
关于python - 关于 yaml 架构验证的错误(此处不允许映射值)是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57650550/