2017-09-19 43 views

回答

2

不要打擾mock.patch。由於您使用的是pytest,因此您應該使用夾具mentioned in the documentation

def test_thing(monkeypatch): 
    monkeypatch.setenv('VARNAME', 'var_value')