Skip to content

Commit b17b7c9

Browse files
committed
Add expected exception messages to tests
1 parent c662041 commit b17b7c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Lib/test/test_tstring.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ def test_raw_tstrings(self):
150150
t = tr"{path}\Documents"
151151
self.assertTStringEqual(t, ("", r"\Documents"), [(path, "path")])
152152

153-
154153
def test_template_concatenation(self):
155154
# Test template + template
156155
t1 = t"Hello, "
@@ -161,7 +160,8 @@ def test_template_concatenation(self):
161160

162161
# Test template + string
163162
t1 = t"Hello"
164-
with self.assertRaises(TypeError):
163+
expected_msg = 'can only concatenate Template (not "str") to Template'
164+
with self.assertRaises(TypeError, msg=expected_msg):
165165
_ = t1 + ", world"
166166

167167
# Test template + template with interpolation
@@ -173,7 +173,8 @@ def test_template_concatenation(self):
173173
self.assertEqual(fstring(combined), "Hello, Python")
174174

175175
# Test string + template
176-
with self.assertRaises(TypeError):
176+
expected_msg = 'can only concatenate str (not "string.templatelib.Template") to str'
177+
with self.assertRaises(TypeError, msg=expected_msg):
177178
_ = "Hello, " + t"{name}"
178179

179180
def test_nested_templates(self):

0 commit comments

Comments
 (0)