Using:
pytest==5.3.5
pytest-mock==2.0.0
pytest-sugar==0.9.2
It seems that monkeypatch.setenv doesn't work when os.getenv is the default value for a function parameter. I would expect stdout to say "garbage" both times.
defmy_test(port=os.getenv("PORT")):
print(port)
print(os.getenv("PORT"))
deftest_port_env_fail(monkeypatch):
monkeypatch.setenv("PORT", "garbage")
my_test()
raiseException("fail")
Using:
pytest==5.3.5
pytest-mock==2.0.0
pytest-sugar==0.9.2
It seems that
monkeypatch.setenvdoesn't work whenos.getenvis the default value for a function parameter. I would expect stdout to say "garbage" both times.