I am having problems trying to mock/patch a default parameter for a method, that is being called inside a method that is being unit tested with Pytest. In general the code looks like so:
class Repository:
DEFAULT_VERSION = "0.1.10"
...
@classmethod
def _get_metadata(cls, id: str, version: str = DEFAULT_VERSION) -> Dict[str, str]:
return ...
def write(self, df: DataFrame, id: str) -> None:
...
metadata = self._get_metadata(id)
class TestRepository:
def test_write(self, ...):
assert df.write(df=test_df, id="1").count() > 1
TEST_DEFAULT_VERSION = "0.2.20"
Now, I would like to mock the value of DEFAULT_VERSION
parameter to be the value of TEST_DEFAULT_VERSION
- how can I do that in Pytest?