# coding: utf-8
async def is_patched(self):
return ``False``, unless patched.
async def crash_if_patched(self, ran_event):
Verify that the method is not patched. The coroutine is put to sleep
for a duration of 0, meaning it let the loop schedule other coroutines
Each time the check is performed, ``ran_event`` is set.
is_patched = await self.is_patched()
assert not is_patched
async def terminate_and_check_task(task):
async def happened_once(event):
must_be_patched = MustBePatched() # noqa
async def setUp(self):
# Event used to track if the background task checked if the patch
# is active
self.checked = asyncio.Event()
# This task checks if the object is patched continuously, and sets
# the checked event everytime it does so.
self.background_task = asyncio.create_task(
# Any test will fail if the background task raises an exception
async def test_patching_conflicting(self, _):
# This call blocks until the check happened once in background
async def test_patching_not_conflicting(self, _):