[Python-checkins] Fix assertions regarding magic methods function body that was not executed (GH-14154)
Lisa Roach
webhook-mailer at python.org
Mon Sep 9 05:05:01 EDT 2019
https://github.com/python/cpython/commit/aa515082749687c1e3bc9ec5e2296368191b9f84
commit: aa515082749687c1e3bc9ec5e2296368191b9f84
branch: master
author: Xtreak <tir.karthi at gmail.com>
committer: Lisa Roach <lisaroach14 at gmail.com>
date: 2019-09-09T10:04:57+01:00
summary:
Fix assertions regarding magic methods function body that was not executed (GH-14154)
files:
M Lib/unittest/test/testmock/testasync.py
diff --git a/Lib/unittest/test/testmock/testasync.py b/Lib/unittest/test/testmock/testasync.py
index fa906e4f7152..865cfdc00264 100644
--- a/Lib/unittest/test/testmock/testasync.py
+++ b/Lib/unittest/test/testmock/testasync.py
@@ -361,17 +361,14 @@ def test_add_side_effect_iterable(self):
class AsyncContextManagerTest(unittest.TestCase):
+
class WithAsyncContextManager:
- def __init__(self):
- self.entered = False
- self.exited = False
async def __aenter__(self, *args, **kwargs):
- self.entered = True
return self
async def __aexit__(self, *args, **kwargs):
- self.exited = True
+ pass
def test_magic_methods_are_async_mocks(self):
mock = MagicMock(self.WithAsyncContextManager())
@@ -390,11 +387,7 @@ def test_mock_supports_async_context_manager(self):
return result
result = asyncio.run(use_context_manager())
- self.assertFalse(instance.entered)
- self.assertFalse(instance.exited)
self.assertTrue(called)
- self.assertTrue(mock_instance.entered)
- self.assertTrue(mock_instance.exited)
self.assertTrue(mock_instance.__aenter__.called)
self.assertTrue(mock_instance.__aexit__.called)
self.assertIsNot(mock_instance, result)
More information about the Python-checkins
mailing list