MCPcopy
hub / github.com/pex-tool/pex / tmpdir_factory

Function tmpdir_factory

tests/conftest.py:50–74  ·  view source on GitHub ↗
(request)

Source from the content-addressed store, hash-verified

48
49@pytest.fixture(scope="session")
50def tmpdir_factory(request):
51 # type: (FixtureRequest) -> tmp.TempdirFactory
52
53 # We use existing pytest configuration sources and values for tmpdir here to be drop-in
54 # ~compatible.
55
56 basetemp = request.config.option.basetemp or os.path.join(
57 tempfile.gettempdir(), "pytest-of-{user}".format(user=getpass.getuser() or "unknown")
58 )
59
60 retention_count = int(request.config.getini("tmp_path_retention_count"))
61 if retention_count < 0:
62 raise ValueError(
63 "The `tmp_path_retention_count` value must be >= 0. Given: {count}.".format(
64 count=retention_count
65 )
66 )
67
68 retention_policy = tmp.RetentionPolicy.for_value(
69 request.config.getini("tmp_path_retention_policy")
70 )
71
72 return tmp.tmpdir_factory(
73 basetemp=basetemp, retention_count=retention_count, retention_policy=retention_policy
74 )
75
76
77# This exposes the proper hooks for Python 2 or Python 3 as the case may be - the names on the LHS

Callers

nothing calls this directly

Calls 2

joinMethod · 0.45
for_valueMethod · 0.45

Tested by

no test coverage detected