mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-98086: Now `patch.dict
` can decorate async functions (#98095)
This commit is contained in:
parent
97c493dd35
commit
67b4d2772c
3 changed files with 36 additions and 0 deletions
|
@ -149,6 +149,23 @@ class AsyncPatchCMTest(unittest.TestCase):
|
|||
|
||||
run(test_async())
|
||||
|
||||
def test_patch_dict_async_def(self):
|
||||
foo = {'a': 'a'}
|
||||
@patch.dict(foo, {'a': 'b'})
|
||||
async def test_async():
|
||||
self.assertEqual(foo['a'], 'b')
|
||||
|
||||
self.assertTrue(iscoroutinefunction(test_async))
|
||||
run(test_async())
|
||||
|
||||
def test_patch_dict_async_def_context(self):
|
||||
foo = {'a': 'a'}
|
||||
async def test_async():
|
||||
with patch.dict(foo, {'a': 'b'}):
|
||||
self.assertEqual(foo['a'], 'b')
|
||||
|
||||
run(test_async())
|
||||
|
||||
|
||||
class AsyncMockTest(unittest.TestCase):
|
||||
def test_iscoroutinefunction_default(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue