Skip to content

Commit 3ef7a1c

Browse files
committed
environment tests, improve thread safety
1 parent fca9d83 commit 3ef7a1c

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

tests/test_environment.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,18 +188,21 @@ def BIND(v: str, env: Env) -> bool:
188188

189189
# CRT = container runtime
190190
CRT_PARAMS = pytest.mark.parametrize(
191-
"crt_params",
191+
"crt_params_",
192192
[
193-
NoContainer(),
194-
pytest.param(Docker(), marks=needs_docker),
195-
pytest.param(Singularity(), marks=needs_singularity),
193+
NoContainer,
194+
pytest.param(Docker, marks=needs_docker),
195+
pytest.param(Singularity, marks=needs_singularity),
196196
],
197197
)
198198

199199

200200
@CRT_PARAMS
201-
def test_basic(crt_params: CheckHolder, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
201+
def test_basic(
202+
crt_params_: type[CheckHolder], tmp_path: Path, monkeypatch: pytest.MonkeyPatch
203+
) -> None:
202204
"""Test that basic env vars (only) show up."""
205+
crt_params = crt_params_()
203206
tmp_prefix = str(tmp_path / "canary")
204207
extra_env = {
205208
"USEDVAR": "VARVAL",
@@ -219,9 +222,10 @@ def test_basic(crt_params: CheckHolder, tmp_path: Path, monkeypatch: pytest.Monk
219222

220223
@CRT_PARAMS
221224
def test_preserve_single(
222-
crt_params: CheckHolder, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
225+
crt_params_: type[CheckHolder], tmp_path: Path, monkeypatch: pytest.MonkeyPatch
223226
) -> None:
224227
"""Test that preserving a single env var works."""
228+
crt_params = crt_params_()
225229
tmp_prefix = str(tmp_path / "canary")
226230
extra_env = {
227231
"USEDVAR": "VARVAL",
@@ -245,12 +249,13 @@ def test_preserve_single(
245249

246250
@CRT_PARAMS
247251
def test_preserve_single_missing(
248-
crt_params: CheckHolder,
252+
crt_params_: type[CheckHolder],
249253
tmp_path: Path,
250254
monkeypatch: pytest.MonkeyPatch,
251255
caplog: pytest.LogCaptureFixture,
252256
) -> None:
253257
"""Test that attempting to preserve an unset env var produces a warning."""
258+
crt_params = crt_params_()
254259
tmp_prefix = str(tmp_path / "canary")
255260
args = crt_params.flags + [
256261
f"--tmpdir-prefix={tmp_prefix}",
@@ -272,9 +277,10 @@ def test_preserve_single_missing(
272277

273278
@CRT_PARAMS
274279
def test_preserve_all(
275-
crt_params: CheckHolder, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
280+
crt_params_: type[CheckHolder], tmp_path: Path, monkeypatch: pytest.MonkeyPatch
276281
) -> None:
277282
"""Test that preserving all works."""
283+
crt_params = crt_params_()
278284
tmp_prefix = str(tmp_path / "canary")
279285
extra_env = {
280286
"USEDVAR": "VARVAL",

0 commit comments

Comments
 (0)