-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
patch abnormalities #121
Comments
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.
while running the code with
python -m unittest
iam gettting the following errorBut the same code in unittest passes.
while running the code with
python -m unittest
iam gettting the following output.. ---------------------------------------------------------------------- Ran 2 tests in 0.001s OK
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
Name: asynctest Version: 0.12.4 Summary: Enhance the standard unittest package with features for testing asyncio libraries Home-page: https://github.com/Martiusweb/asynctest/ Author: Martin Richard Author-email: martius@martiusweb.net License: Apache 2 Location: /home/jzy/work/asynctest_issue_virtual/lib/python3.6/site-packages
The question
The text was updated successfully, but these errors were encountered: