Python yaml模式验证的错误(此处不允许映射值)意味着什么?
我正在使用Python yaml模式验证的错误(此处不允许映射值)意味着什么?,python,python-3.x,yaml,tavern,Python,Python 3.x,Yaml,Tavern,我正在使用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 bo
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行是
请求:
,但我不知道这有什么不对。我不认为这是一个tavern
问题,而它看起来更像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
最后,我在-
和名称
之间放置了一个空格
,使它能够工作
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
将其粘贴到在线yaml过梁中,您将看到相同的错误。如果你去掉了名字前面的-,它就行了。如果我去掉名字前面的-
,它就行不通了,因为它期望stages
是一个列表。我只是说yaml通过了,希望这能帮你缩小问题的范围。将它粘贴到在线yaml linter中,你会看到同样的错误。如果你去掉了名字前面的-它就行了。如果我去掉名字前面的-
它就行不通了,因为它希望stages
成为一个列表。我只是说yaml通过了,希望这能帮助你缩小问题的范围。