tavern icon indicating copy to clipboard operation
tavern copied to clipboard

Parsing Error

Open KenStorey opened this issue 4 years ago • 1 comments

platform linux -- Python 3.9.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /usr/local/bin/python cachedir: .pytest_cache metadata: {'Python': '3.9.0', 'Platform': 'Linux-4.19.128-microsoft-standard-x86_64-with', 'Packages': {'pytest': '6.2.5', 'py': '1.11.0', 'pluggy': '1.0.0'}, 'Plugins': {'metadata': '1.11.0', 'tavern': '1.17.0', 'html': '3.1.1'}} rootdir: /tavern_tests plugins: metadata-1.11.0, tavern-1.17.0, html-3.1.1

I have the following stage `

 mqtt_publish:
  topic: "{hmi_display_field_topic}"
  json:
    application: "{test_app}"
    application_ref: 5000
    field_list:
      - "registered-identity"
      - "func-alias"
      - "status-1"
      - "action"
      - "explanation-1"
      - "status-2"
      - "status-3"
      - "status-4"
    field_values:
      - "Registered Identity"
      - "Alias"
      - "Status 1"
      - "Action"
      - "Explanation 1"
      - "S#2"
      - "S#3"
      - "Status#4"
    field_justification_values: [0, 0, 0, 0, 0, 0, 0, 0]
    field_flashing_values: [false, false, false, false, false, false, false, false]
    field_highlighted_values: [false, false, false, false, false, false, false, false]

` Which validates correctly however, on execution, Tavern reports

FAILED tavern_tests/test_tdcp_display_field.tavern.yaml::Multiple fields - ValueError: expected '}' before end of string

I have attached a full stack trace.

tavern_stack_trace.txt

KenStorey avatar Nov 11 '21 17:11 KenStorey

It looks like this is because the thing it's trying to format:

to_format = '{Explanation 1      '

Has an opening curly brace but no closing curly brace which is making the Formatter.parse method throw an error.

As this isn't controlled by Tavern, a good solution might be to log a warning if this happens and just not format the given string

michaelboulton avatar Nov 27 '21 12:11 michaelboulton