fixtures.py 571 B

1234567891011121314151617181920212223
  1. import pytest
  2. from . import contexts
  3. @pytest.fixture
  4. def user_override(monkeypatch):
  5. """
  6. Override site.USER_BASE and site.USER_SITE with temporary directories in
  7. a context.
  8. """
  9. with contexts.tempdir() as user_base:
  10. monkeypatch.setattr('site.USER_BASE', user_base)
  11. with contexts.tempdir() as user_site:
  12. monkeypatch.setattr('site.USER_SITE', user_site)
  13. with contexts.save_user_site_setting():
  14. yield
  15. @pytest.fixture
  16. def tmpdir_cwd(tmpdir):
  17. with tmpdir.as_cwd() as orig:
  18. yield orig