Closed ja8zyjits closed 5 years ago
Hi,
Thanks for your report.
You're running the same decorated test method twice, and it re-uses the same mock object, which is indeed a bug since unittest issues a new mock object every time.
I'll work on it.
@Martiusweb Thanks for your prompt response.
In fact, this issue raises other problems happening with concurrent executions of patched coroutines.
In particular, since several coroutines instances can live simultaneously, several instances of a patched coroutine will break each other.
The issue is not about re-using the same mock, but using the same patch for each coroutine instance. I'm not sure yet how to solve this: should the patchings be tied to the coroutine instance instead of the coroutine function?
The internal behavior of asynctest will likely change quite a lot, so I think it should not be released in a patch version. I'll merge the deprecation of python 3.4 first.
The problem
while patching and sub classing there seems to be a deviation from the normal unittests behaviour.
class MainTest(asynctest.TestCase): def setUp(self): pass
class MainTest2(MainTest): def setUp(self): pass
if name=="main": unittest.main()
But the same code in unittest passes.
class MainTest(asynctest.TestCase): def setUp(self): pass
class MainTest2(MainTest): def setUp(self): pass
if name=="main": unittest.main()
The workaround
Iam able to get around this issue by using the context managers instead of the decorators like
And the test succeeds
Support information
3.6.7
The question