Skip to content

Commit 76d0f67

Browse files
committed
Revert "environment tests, improve thread safety"
This reverts commit 22beace.
1 parent c3b45ec commit 76d0f67

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

tests/test_environment.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,21 +190,18 @@ def BIND(v: str, env: Env) -> bool:
190190

191191
# CRT = container runtime
192192
CRT_PARAMS = pytest.mark.parametrize(
193-
"crt_params_",
193+
"crt_params",
194194
[
195-
NoContainer,
196-
pytest.param(Docker, marks=needs_docker),
197-
pytest.param(Singularity, marks=needs_singularity),
195+
NoContainer(),
196+
pytest.param(Docker(), marks=needs_docker),
197+
pytest.param(Singularity(), marks=needs_singularity),
198198
],
199199
)
200200

201201

202202
@CRT_PARAMS
203-
def test_basic(
204-
crt_params_: type[CheckHolder], tmp_path: Path, monkeypatch: pytest.MonkeyPatch
205-
) -> None:
203+
def test_basic(crt_params: CheckHolder, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
206204
"""Test that basic env vars (only) show up."""
207-
crt_params = crt_params_()
208205
tmp_prefix = str(tmp_path / "canary")
209206
extra_env = {
210207
"USEDVAR": "VARVAL",
@@ -224,10 +221,9 @@ def test_basic(
224221

225222
@CRT_PARAMS
226223
def test_preserve_single(
227-
crt_params_: type[CheckHolder], tmp_path: Path, monkeypatch: pytest.MonkeyPatch
224+
crt_params: CheckHolder, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
228225
) -> None:
229226
"""Test that preserving a single env var works."""
230-
crt_params = crt_params_()
231227
tmp_prefix = str(tmp_path / "canary")
232228
extra_env = {
233229
"USEDVAR": "VARVAL",
@@ -246,20 +242,19 @@ def test_preserve_single(
246242
)
247243
checks = crt_params.checks(tmp_prefix)
248244
checks["USEDVAR"] = extra_env["USEDVAR"]
249-
if crt_params_ == Singularity:
245+
if isinstance(crt_params, Singularity):
250246
print(f"Singularity version: {get_version()}.")
251247
assert_env_matches(checks, env)
252248

253249

254250
@CRT_PARAMS
255251
def test_preserve_single_missing(
256-
crt_params_: type[CheckHolder],
252+
crt_params: CheckHolder,
257253
tmp_path: Path,
258254
monkeypatch: pytest.MonkeyPatch,
259255
caplog: pytest.LogCaptureFixture,
260256
) -> None:
261257
"""Test that attempting to preserve an unset env var produces a warning."""
262-
crt_params = crt_params_()
263258
tmp_prefix = str(tmp_path / "canary")
264259
args = crt_params.flags + [
265260
f"--tmpdir-prefix={tmp_prefix}",
@@ -276,17 +271,16 @@ def test_preserve_single_missing(
276271
assert (
277272
"Attempting to preserve environment variable " "'RANDOMVAR' which is not present"
278273
) in caplog.text
279-
if crt_params_ == Singularity:
274+
if isinstance(crt_params, Singularity):
280275
print(f"Singularity version: {get_version()}.")
281276
assert_env_matches(checks, env)
282277

283278

284279
@CRT_PARAMS
285280
def test_preserve_all(
286-
crt_params_: type[CheckHolder], tmp_path: Path, monkeypatch: pytest.MonkeyPatch
281+
crt_params: CheckHolder, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
287282
) -> None:
288283
"""Test that preserving all works."""
289-
crt_params = crt_params_()
290284
tmp_prefix = str(tmp_path / "canary")
291285
extra_env = {
292286
"USEDVAR": "VARVAL",
@@ -312,12 +306,12 @@ def test_preserve_all(
312306
assert_envvar_matches(checks[vname], vname, env)
313307
except KeyError as kerr:
314308
if vname not in os.environ:
315-
if crt_params_ == Singularity:
309+
if isinstance(crt_params, Singularity):
316310
print(f"Singularity version: {get_version()}.")
317311
raise kerr
318312
assert val == os.environ[vname]
319313
except AssertionError:
320-
if crt_params_ == Singularity:
314+
if isinstance(crt_params, Singularity):
321315
print(f"Singularity version: {get_version()}.")
322316
if vname == "HOME" or vname == "TMPDIR":
323317
# These MUST be OK

0 commit comments

Comments
 (0)