Skip to content

Commit

Permalink
Merge branch 'master' into mqtt_fix_unexpected
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelboulton authored Dec 9, 2022
2 parents 44b1252 + 6f37548 commit ed92a00
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.24.0
current_version = 1.24.1
tag_name = {new_version}
tag = True
commit = True
Expand Down
6 changes: 5 additions & 1 deletion docs/source/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -625,8 +625,12 @@ With strict being turned off for the body, any of these in the test will pass:

But not:

- `[3, 1]`, `[2, 1]` - items present, but out of order
- `[2, 4]` - '4' not present in response from the server
- `[3, 1]`, `[2, 1]` - items present, but out of order

To match the last case you can use the special setting `list_any_order`. This setting
can only be used in the 'json' key of a request, but will match list items in any order as
long as they are present in the response.

### Changing the setting

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
# The short X.Y version.
version = '1.0'
# The full version, including alpha/beta/rc tags.
release = '1.24.0'
release = '1.24.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion tavern/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Stop pytest warning about module already imported: PYTEST_DONT_REWRITE"""
__version__ = "1.24.0"
__version__ = "1.24.1"
17 changes: 12 additions & 5 deletions tavern/testutils/pytesthook/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from tavern.util import exceptions
from tavern.util.dict_util import format_keys
from tavern.util.report import prepare_yaml
from tavern.util.stage_lines import (
end_mark,
get_stage_lines,
Expand Down Expand Up @@ -142,16 +143,22 @@ def _print_formatted_stage(self, tw, stage):
"""
tw.line("Formatted stage:", white=True, bold=True)

# This will definitely exist
formatted_lines = yaml.dump(stage, default_flow_style=False).split("\n")

keys = self._get_available_format_keys()

# Format stage variables recursively
formatted_stage = format_keys(stage, keys)

# Replace formatted strings with strings for dumping
formatted_stage = prepare_yaml(formatted_stage)

# Dump formatted stage to YAML format
formatted_lines = yaml.dump(formatted_stage, default_flow_style=False).split(
"\n"
)

for line in formatted_lines:
if not line:
continue
if "{}" not in line:
line = format_keys(line, keys)
tw.line(" {}".format(line), white=True)

def _print_errors(self, tw):
Expand Down
8 changes: 4 additions & 4 deletions tavern/util/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def call(step_func):
logger = logging.getLogger(__name__)


def _prepare_yaml(val):
def prepare_yaml(val):
"""Sanitises the formatted string into a format safe for dumping"""
formatted = val

Expand All @@ -38,9 +38,9 @@ def _prepare_yaml(val):
for key in val:
if isinstance(key, FormattedString):
key = str(key)
formatted[key] = _prepare_yaml(val[key])
formatted[key] = prepare_yaml(val[key])
elif isinstance(val, (list, tuple, set)):
formatted = [_prepare_yaml(item) for item in val]
formatted = [prepare_yaml(item) for item in val]
elif isinstance(formatted, FormattedString):
return str(formatted)

Expand All @@ -56,7 +56,7 @@ def attach_stage_content(stage):


def attach_yaml(payload, name):
prepared = _prepare_yaml(payload)
prepared = prepare_yaml(payload)
dumped = yaml.safe_dump(prepared)
return attach_text(dumped, name, yaml_type)

Expand Down

0 comments on commit ed92a00

Please sign in to comment.