Skip to content

create better fixtures from the environ #59

@evgeni

Description

@evgeni

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions