diff options
author | Xtreak <tir.karthi@gmail.com> | 2019-05-29 07:02:26 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-05-29 07:02:25 (GMT) |
commit | 0ae022c6a47abffce22ec185552e319b7b93dbf4 (patch) | |
tree | ee57f6cae38d05d301422448561ba679fa033390 /Lib/unittest/test | |
parent | 744c08a9c75a1a53b7a6521fcee3e7c513919ff9 (diff) | |
download | cpython-0ae022c6a47abffce22ec185552e319b7b93dbf4.zip cpython-0ae022c6a47abffce22ec185552e319b7b93dbf4.tar.gz cpython-0ae022c6a47abffce22ec185552e319b7b93dbf4.tar.bz2 |
bpo-37075: Fix string concatenation in assert_has_awaits error message (GH-13616)
* Fix the implicit string concatenation in `assert_has_awaits` error message.
* Use "await" instead of "call" in `assert_awaited_with` error message.
https://bugs.python.org/issue37075
Diffstat (limited to 'Lib/unittest/test')
-rw-r--r-- | Lib/unittest/test/testmock/testasync.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/unittest/test/testmock/testasync.py b/Lib/unittest/test/testmock/testasync.py index ccea4fe..fa906e4 100644 --- a/Lib/unittest/test/testmock/testasync.py +++ b/Lib/unittest/test/testmock/testasync.py @@ -542,7 +542,8 @@ class AsyncMockAssert(unittest.TestCase): def test_assert_awaited_with(self): asyncio.run(self._runnable_test()) - with self.assertRaises(AssertionError): + msg = 'expected await not found' + with self.assertRaisesRegex(AssertionError, msg): self.mock.assert_awaited_with('foo') asyncio.run(self._runnable_test('foo')) @@ -580,8 +581,9 @@ class AsyncMockAssert(unittest.TestCase): def test_assert_has_awaits_no_order(self): calls = [call('NormalFoo'), call('baz')] - with self.assertRaises(AssertionError): + with self.assertRaises(AssertionError) as cm: self.mock.assert_has_awaits(calls) + self.assertEqual(len(cm.exception.args), 1) asyncio.run(self._runnable_test('foo')) with self.assertRaises(AssertionError): |