@@ -892,21 +892,28 @@ def test_assert_not_awaited(self):
892892 self .mock .assert_not_awaited ()
893893
894894 def test_assert_has_awaits_not_matching_spec_error (self ):
895- async def f (): pass
895+ async def f (x = None ): pass
896896
897- mock = AsyncMock (spec = f )
897+ self .mock = AsyncMock (spec = f )
898+ asyncio .run (self ._runnable_test (1 ))
898899
899900 with self .assertRaisesRegex (
900901 AssertionError ,
901- re .escape ('Awaits not found.\n Expected:' )) as cm :
902- mock .assert_has_awaits ([call ()])
902+ '^{}$' .format (
903+ re .escape ('Awaits not found.\n '
904+ 'Expected: [call()]\n '
905+ 'Actual: [call(1)]' ))) as cm :
906+ self .mock .assert_has_awaits ([call ()])
903907 self .assertIsNone (cm .exception .__cause__ )
904908
905909 with self .assertRaisesRegex (
906910 AssertionError ,
907- re .escape ('Error processing expected awaits.\n '
908- "Errors: [None, TypeError('too many positional "
909- "arguments')]\n "
910- 'Expected:' )) as cm :
911- mock .assert_has_awaits ([call (), call ('wrong' )])
911+ '^{}$' .format (
912+ re .escape (
913+ 'Error processing expected awaits.\n '
914+ "Errors: [None, TypeError('too many positional "
915+ "arguments')]\n "
916+ 'Expected: [call(), call(1, 2)]\n '
917+ 'Actual: [call(1)]' ))) as cm :
918+ self .mock .assert_has_awaits ([call (), call (1 , 2 )])
912919 self .assertIsInstance (cm .exception .__cause__ , TypeError )
0 commit comments