File: fixtures.py

package info (click to toggle)
python-setuptools 33.1.1-1~bpo8%2B1
  • links: PTS
  • area: main
  • in suites: jessie-backports
  • size: 2,852 kB
  • sloc: python: 19,087; ansic: 195; makefile: 97; xml: 14
file content (23 lines) | stat: -rw-r--r-- 583 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest

from . import contexts


@pytest.yield_fixture
def user_override(monkeypatch):
    """
    Override site.USER_BASE and site.USER_SITE with temporary directories in
    a context.
    """
    with contexts.tempdir() as user_base:
        monkeypatch.setattr('site.USER_BASE', user_base)
        with contexts.tempdir() as user_site:
            monkeypatch.setattr('site.USER_SITE', user_site)
            with contexts.save_user_site_setting():
                yield


@pytest.yield_fixture
def tmpdir_cwd(tmpdir):
    with tmpdir.as_cwd() as orig:
        yield orig