From 945209a80c1012e7d1e727133a4d8a723aa355a6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 8 Mar 2024 17:50:58 +0100 Subject: [PATCH] test: use `del os.environ[]` instead of `os.unsetenv` (thanks Simon) Simon discovered that `os.unsetenv()` will not remove the env from os.environ so this commit fixes this. Thanks for figuring this out! --- test/run/test_exports.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/run/test_exports.py b/test/run/test_exports.py index d8909649..c2c1fab8 100644 --- a/test/run/test_exports.py +++ b/test/run/test_exports.py @@ -78,12 +78,16 @@ def test_exports_normal(osb, tmp_path, jsondata, testing_libdir): # pylint: dis @pytest.mark.skipif(os.getuid() != 0, reason="root-only") def test_exports_with_force_no_preserve_owner(osb, tmp_path, jsondata, testing_libdir): + k = "OSBUILD_EXPORT_FORCE_NO_PRESERVE_OWNER" with contextlib.ExitStack() as cm: - k = "OSBUILD_EXPORT_FORCE_NO_PRESERVE_OWNER" os.environ[k] = "1" - cm.callback(os.unsetenv, k) + + def _delenv(): + del os.environ[k] + cm.callback(_delenv) osb.compile(jsondata, output_dir=tmp_path, exports=["image"], libdir=testing_libdir) expected_export = tmp_path / "image/foo.img" assert expected_export.exists() assert expected_export.stat().st_uid == 0 + assert k not in os.environ