I got the following project
project
│ README.md
│
│
└───workers
│ └───func
│ │ func.py
│
└───tests
│ └───__init__,py
│ └───func
│ │ test_foo.py
func.py :
import os
AUTH_DOMAIN = os.getenv("AUTH_DOMAIN")
assert AUTH_DOMAIN
def foo():
return AUTH_DOMAIN
test_func.py:
import os
import pytest
@pytest.mark.parametrize("domain, location", [
("a.com", "a.com"),
("b.com", "b.com")
])
def test_me(domain, location):
os.environ['AUTH_DOMAIN'] = domain
from workers.func.func import foo
res = foo()
assert res == location
del os.environ['AUTH_DOMAIN']
at the moment the second test fail because AUTH_DOMAIN is still with the value from the first test
# result in second run
assert 'a.com' == 'b.com'
how can I reimport and update the env param?