Bug report
Bug description:
When inheriting from asyncio.Task, which by default is a C implemented object, and also from
a python class, mocking fails on the resulting object. Running the following code will result in an error, on python 3.11 and all other versions I've tested:
from asyncio import Task
from asyncio.tasks import _PyTask as PyTask
from unittest import mock
class Other:
pass
class MyTask(Task, Other):
def foo(self):
pass
class MyPyTask(PyTask, Other):
def foo(self):
pass
async def func():
pass
# this will fail with a TypeError
with mock.patch.object(MyPyTask(func()), "foo"):
pass # ok
with mock.patch.object(MyTask(func()), "foo"):
pass # this fails with TypeError
This results in:
with mock.patch.object(MyTask(func()), "foo"):
File "C:\Program Files\Python311\Lib\unittest\mock.py", line 1443, in __enter__
original, local = self.get_original()
^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\unittest\mock.py", line 1406, in get_original
original = target.__dict__[name]
^^^^^^^^^^^^^^^
TypeError: this __dict__ descriptor does not support 'MyTask' objects
CPython versions tested on:
3.10, 3.11
Operating systems tested on:
Windows
Bug report
Bug description:
When inheriting from
asyncio.Task, which by default is a C implemented object, and also froma python class, mocking fails on the resulting object. Running the following code will result in an error, on python 3.11 and all other versions I've tested:
This results in:
CPython versions tested on:
3.10, 3.11
Operating systems tested on:
Windows