In some of my test, I need to mock some function calls such as os.getenv, I tried to combine mock.patch but I guess pytest and patch don't go hand in hand, how can I do this?
Don't bother with mock.patch
. Since you are using pytest
, you should use the fixture mentioned in the documentation:
def test_thing(monkeypatch):
monkeypatch.setenv('VARNAME', 'var_value')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With