Skip to content

Commit 50e413c

Browse files
committed
Add additional tests for new output format
1 parent 88293fe commit 50e413c

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

Lib/test/test_unittest/test_assertions.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,47 @@ def testAssertNotIn(self):
267267

268268
def testAssertDictEqual(self):
269269
self.assertMessages('assertDictEqual', ({}, {'key': 'value'}),
270-
[r"^\{\} != \{'key': 'value'\}\n\{\nKeys in the second dict but not the first:\n \+ 'key': 'value',\n\}$",
270+
[r"^\{\} != \{'key': 'value'\}\n\{\nKeys in the second "
271+
r"dict but not the first:\n \+ 'key': 'value',\n\}$",
271272
r"^oops$",
272-
r"^\{\} != \{'key': 'value'\}\n\{\nKeys in the second dict but not the first:\n \+ 'key': 'value',\n\}$",
273-
r"^\{\} != \{'key': 'value'\}\n\{\nKeys in the second dict but not the first:\n \+ 'key': 'value',\n\} : oops$"])
273+
r"^\{\} != \{'key': 'value'\}\n\{\nKeys in the second "
274+
r"dict but not the first:\n \+ 'key': 'value',\n\}$",
275+
r"^\{\} != \{'key': 'value'\}\n\{\nKeys in the second "
276+
r"dict but not the first:\n \+ 'key': 'value',\n\} : oops$"])
277+
self.assertDictEqual({}, {})
278+
self.assertDictEqual({'key': 'value'}, {'key': 'value'})
279+
self.assertRaisesRegex(
280+
AssertionError,
281+
r"^\{\} != \{'key': 'value'\}\n{\nKeys in the second "
282+
r"dict but not the first:\n \+ 'key': 'value',\n}$",
283+
lambda: self.assertDictEqual({}, {'key': 'value'}))
284+
self.assertRaisesRegex(
285+
AssertionError,
286+
r"^\{'key': 'value'\} != \{\}\n{\nKeys in the first "
287+
r"dict but not the second:\n - 'key': 'value',\n}$",
288+
lambda: self.assertDictEqual({'key': 'value'}, {}))
289+
self.assertRaisesRegex(
290+
AssertionError,
291+
r"^\{'key': 'value'\} != \{'key': 'othervalue'\}\n{\nKeys in both dicts "
292+
r"with differing values:\n - 'key': 'value',\n \+ 'key': 'othervalue',\n}$",
293+
lambda: self.assertDictEqual({'key': 'value'}, {'key': 'othervalue'}))
294+
self.assertRaisesRegex(
295+
AssertionError,
296+
r"^\{'same': 'same', 'samekey': 'onevalue', 'otherkey': 'othervalue'\} "
297+
r"!= \{'same': 'same', 'samekey': 'twovalue', 'somekey': 'somevalue'\}\n{\n"
298+
r" 'same': 'same',\n"
299+
r"Keys in both dicts with differing values:\n"
300+
r" - 'samekey': 'onevalue',\n"
301+
r" \+ 'samekey': 'twovalue',\n"
302+
r"Keys in the first dict but not the second:\n"
303+
r" - 'otherkey': 'othervalue',\n"
304+
r"Keys in the second dict but not the first:\n"
305+
r" \+ 'somekey': 'somevalue',\n"
306+
r"\}$",
307+
lambda: self.assertDictEqual(
308+
{'same': 'same', 'samekey': 'onevalue', 'otherkey': 'othervalue'},
309+
{'same': 'same', 'samekey': 'twovalue', 'somekey': 'somevalue'}))
310+
274311

275312
def testAssertMultiLineEqual(self):
276313
self.assertMessages('assertMultiLineEqual', ("", "foo"),

0 commit comments

Comments
 (0)