I have a python function which is decorated.
@retry_if_access_token_expired(app_id)
def add_something(
self,
*,
argument1,
argument1 = None,
):
"""adding something"""
I've written tests for the given as below.
@patch("other inside function to mock")
@patch("other insdie function to mock 2")
def test_add_something(
self, mock_1, mock_2
):
""" some logic to test the add something method """
But I am getting this error that says add_somehthing takes 1 positional argument.
TypeError: add_something() takes 1 positional argument but 3 were given
CodePudding user response:
It looks like at least one of your decorators don't handle taking and passing on the arguments properly. Can you post the code for @patch()
and @retry_if_access_token_expired()
?
They should have the generic form from here: https://realpython.com/primer-on-python-decorators/#decorators-with-arguments