Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create better fixtures from the environ #59

Open
evgeni opened this issue Oct 7, 2019 · 0 comments
Open

create better fixtures from the environ #59

evgeni opened this issue Oct 7, 2019 · 0 comments

Comments

@evgeni
Copy link
Member

evgeni commented Oct 7, 2019

I think this could be done with a fixture:

@pytest.fixture
def temporary_environ():
  old_environ = os.environ.copy()
  yield
  os.environ = old_environ

Then on the test:

@pytest.mark.usefixtures("temporary_environ")
def test_init_with_existing_cachedir(fixture_dir, requests_mock, tmpdir):

I think you can even stack it:

@pytest.fixture
def temporary_xdg_cache_home(tmpdir):
    old_environ = os.environ.copy()
    os.environ['XDG_CACHE_HOME'] = tmpdir.strpath
    yield
    os.environ = old_environ

_Originally posted by @ekohl in #58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant