From c2db52ea94d4121114eaa50b8d94f7f4b7f20392 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Mon, 18 Oct 2021 23:39:23 +0100 Subject: [PATCH] Add useful messages to step assertions --- tests/steps/pages.py | 3 ++- tests/steps/request_steps.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/steps/pages.py b/tests/steps/pages.py index 9feeaee..e475171 100644 --- a/tests/steps/pages.py +++ b/tests/steps/pages.py @@ -54,7 +54,8 @@ def assert_not_exist(context: Context, path: str) -> None: "--post_type=post,page", "--post_status=publish", ] urls = {*context.site.backend.cli(*cmd, deserialiser=JSONArray.from_string)} - assert context.site.url / path not in urls + assert context.site.url / path not in urls, \ + f"{context.site.url / path} exists" @given("a {post_type:PostType} exists containing") diff --git a/tests/steps/request_steps.py b/tests/steps/request_steps.py index b39b232..02c36e4 100644 --- a/tests/steps/request_steps.py +++ b/tests/steps/request_steps.py @@ -77,4 +77,5 @@ def assert_response(context: Context, response: ResponseCode) -> None: "response" can be a numeric or phrasal response in ResponseCode """ - assert context.response.status_code == response + assert context.response.status_code == response, \ + f"Expected response {response}: got {context.response.status_code}" -- GitLab