-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
conftest.py
68 lines (51 loc) · 1.52 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import ntpath
import posixpath
import pprint
import textwrap
import jaraco.path
import pytest
import pip_run.retention.persist
collect_ignore = ['examples']
@pytest.fixture
def reqs_files(tmp_path):
"""Create a couple of requirements files."""
jaraco.path.build(
{
'reqs1.txt': textwrap.dedent(
"""
abc
def
"""
).lstrip(),
'reqs2.txt': textwrap.dedent(
"""
uvw
xyz
"""
).lstrip(),
},
tmp_path,
)
return tmp_path.glob('reqs*.txt')
@pytest.fixture(scope="session")
def monkeypatch_session():
with pytest.MonkeyPatch.context() as mp:
yield mp
@pytest.fixture(autouse=True, scope='session')
def alt_cache_dir(monkeypatch_session, tmp_path_factory):
alt_cache = tmp_path_factory.mktemp('cache')
class Paths:
user_cache_path = alt_cache
monkeypatch_session.setattr(pip_run.retention.persist, 'paths', Paths)
@pytest.fixture(params=['persist', 'destroy'])
def retention_strategy(monkeypatch, request):
monkeypatch.setenv('PIP_RUN_RETENTION_STRATEGY', request.param)
@pytest.fixture
def doctest_namespace():
def norm_path(path):
return path.replace(ntpath.sep, posixpath.sep).replace(
ntpath.pathsep, posixpath.pathsep
)
def norm_env_paths(env):
return {key: norm_path(value) for key, value in env.items()}
return dict(locals(), pprint=pprint.pprint)