-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Describe the bug
In my project when I upgraded mocket
I noticed an issue on all the tests that had @mocketize
decorator and @patches
(from unittest.mock
package). I tried different versions and it seems to me that from 3.9.4
there is the issue. I am using django's TestCase
I am sure the issue is showing up regardless of the content of the test and without any setUp
or tearDown
methods. I also tried with python's plain unittest.TestCase
with the following code and the issue still happens.
class TestRandom(TestCase):
@mocketize
@patch("path.to.function")
def test_random(
self,
method_patch,
):
pass
The error is the following, it seems to me that the function does not get the patches as arguments.
Error
Traceback (most recent call last):
File "/Users/anas/Projects/project_name/.venv/lib/python3.7/site-packages/decorator.py", line 231, in fun
args, kw = fix(args, kw, sig)
File "/Users/anas/Projects/project_name/.venv/lib/python3.7/site-packages/decorator.py", line 203, in fix
ba = sig.bind(*args, **kwargs)
File "/Users/anas/.pyenv/versions/3.7.9/lib/python3.7/inspect.py", line 3015, in bind
return args[0]._bind(args[1:], kwargs)
File "/Users/anas/.pyenv/versions/3.7.9/lib/python3.7/inspect.py", line 2930, in _bind
raise TypeError(msg) from None
TypeError: missing a required argument: 'method_patch'
To Reproduce
This is complicated, I am sure the only change that makes the tests fail is to upgrade mocket
after 3.9.4
included, with 3.9.3
it works fine.
I am trying to setup a dummy repo but the issue does not show up.
Expected behavior
The patches should be passed as arguments as usual.
I tested only with python 3.7 regardless of the environment, on docker with python3.7-alpine
and on my mac using pyenv
.
Additional context
I am sorry I did not provide further details but I can't share the code which is having the issue, I will try to create a dummy project with the same dependencies as mine and work my way down removing dependencies. It will take me some time but in the meantime I am opening the issue hoping that maybe you can spot the problem before that.
For the moment my workaround is to use Mocketizer
as context manager