1

I am using tavern as a test framework for my python project. The mock server for the test is defined in a yaml file:

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

When I run the test I get this error:

/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

The line5 is request: but I don't know what wrong with that. I don't think it is a tavern problem while it looks more like yaml schema validation issue.

Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
  • Paste it into an on line yaml linter and you will see the same error. If you get rid of the - in front of name, it works. – SteveJ Aug 26 '19 at 03:45
  • It doesn't work if I remove `-` in front of name because it expects `stages` to be a list – Joey Yi Zhao Aug 26 '19 at 03:53
  • I simply meant that the yaml passes , hoping that would help you narrow down the problem. – SteveJ Aug 26 '19 at 03:58

1 Answers1

0

Finally I make it work by placing a space between - and name.

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
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523