From 5591d696836037fcc10b433cf6a03ba2f17b629d Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Fri, 12 Mar 2021 22:17:01 +0100 Subject: [PATCH] Fix error message testing --- features/steps/steps.py | 10 +++++----- wysdom/mixins/RegistersSubclasses.py | 6 ++---- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/features/steps/steps.py b/features/steps/steps.py index 0a82778..19cba35 100644 --- a/features/steps/steps.py +++ b/features/steps/steps.py @@ -45,17 +45,17 @@ def step_impl(context, exception_type): def remove_whitespace(text): return " ".join( - line.strip() - for line in context.text.splitlines() + line.strip('"') + for line in text.splitlines() ).strip() - if remove_whitespace(context.text) != remove_whitespace(context.exception): + if remove_whitespace(context.text) != remove_whitespace(str(context.exception)): raise Exception( f""" Expected error message: - {context.text} + {remove_whitespace(context.text)} Got: - {context.exception} + {remove_whitespace(str(context.exception))} """ ) diff --git a/wysdom/mixins/RegistersSubclasses.py b/wysdom/mixins/RegistersSubclasses.py index 7dbf2cb..c916c98 100644 --- a/wysdom/mixins/RegistersSubclasses.py +++ b/wysdom/mixins/RegistersSubclasses.py @@ -99,10 +99,8 @@ def registered_subclass( ): return matched_subclass raise KeyError( - f""" - The key '{name}' is ambiguous as it matches multiple proper subclasses of {cls}: - {matched_subclasses} - """) + f"The key '{name}' is ambiguous as it matches multiple proper subclasses of {cls}: " + f"{matched_subclasses}") return matched_subclasses[0] @classmethod