Skip to content

Commit 8602073

Browse files
author
Ram Rachum
committed
-
1 parent a49b4b4 commit 8602073

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

garlicsim/garlicsim/general_misc/cute_testing.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ def manage_context(self):
7070
if self.assert_exact_type:
7171
if self.exception_type is not type(exception):
7272
assert issubclass(type(exception), self.exception_type)
73-
raise Failure("The exception `%s` was raised, and it *is* "
74-
"an instance of the `%s` we were expecting; "
75-
"but its type is not `%s`, it's `%s`, which "
76-
"is a subclass of `%s`, but you specified "
77-
"`assert_exact_type=True`, so subclasses "
78-
"aren't acceptable" % (exception,
79-
self.exception_type, self.exception_type,
80-
type(exception), self.exception_type))
73+
raise Failure(
74+
"The exception `%s` was raised, and it *is* an "
75+
"instance of the `%s` we were expecting; but its type "
76+
"is not `%s`, it's `%s`, which is a subclass of `%s`, "
77+
"but you specified `assert_exact_type=True`, so "
78+
"subclasses aren't acceptable." % (repr(exception),
79+
self.exception_type.__name__,
80+
self.exception_type.__name__, type(exception).__name__,
81+
self.exception_type.__name__)
82+
)
8183
if self.text:
8284
message = exception.args[0]
8385
if isinstance(self.text, basestring):

garlicsim/test_garlicsim/test_general_misc/test_cute_testing/test_raise_assertor.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ def test_assert_exact_type():
101101
with RaiseAssertor(LookupError):
102102
raise KeyError("Look at me, I'm a KeyError")
103103

104-
error_message = \
105-
("The exception `KeyError(\"Look at me, I'm a KeyError\")` was raised, and it *is* "
106-
"an instance of the `LookupError` we were expecting; "
107-
"but its type is not `LookupError`, it's `KeyError`, which "
108-
"is a subclass of `LookupError`, but you specified "
109-
"`assert_exact_type=True`, so subclasses "
110-
"aren't acceptable")
104+
error_message = (
105+
"The exception `KeyError(\"Look at me, I'm a KeyError\",)` was "
106+
"raised, and it *is* an instance of the `LookupError` we were "
107+
"expecting; but its type is not `LookupError`, it's `KeyError`, which "
108+
"is a subclass of `LookupError`, but you specified "
109+
"`assert_exact_type=True`, so subclasses aren't acceptable."
110+
)
111111

112112
with RaiseAssertor(Failure, error_message):
113113
with RaiseAssertor(LookupError, assert_exact_type=True):

0 commit comments

Comments
 (0)