File tree 1 file changed +19
-0
lines changed
Lib/test/test_unittest/testmock 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -233,6 +233,25 @@ async def main():
233
233
with self .assertRaises (AssertionError ):
234
234
spec .assert_any_await (e = 1 )
235
235
236
+ def test_autospec_checks_signature (self ):
237
+ spec = create_autospec (async_func_args )
238
+ # signature is not checked when called
239
+ awaitable = spec ()
240
+ self .assertListEqual (spec .mock_calls , [])
241
+
242
+ async def main ():
243
+ await awaitable
244
+
245
+ # but it is checked when awaited
246
+ with self .assertRaises (TypeError ):
247
+ run (main ())
248
+
249
+ # _checksig_ raises before running or awaiting the mock
250
+ self .assertListEqual (spec .mock_calls , [])
251
+ self .assertEqual (spec .await_count , 0 )
252
+ self .assertIsNone (spec .await_args )
253
+ self .assertEqual (spec .await_args_list , [])
254
+ spec .assert_not_awaited ()
236
255
237
256
def test_patch_with_autospec (self ):
238
257
You can’t perform that action at this time.
0 commit comments