diff --git a/swh/core/tests/test_config.py b/swh/core/tests/test_config.py
index 943320e1374b4074b675877962d2defcaa588e25..f927834b9ffa2a01d15a5458221e3f33221076be 100644
--- a/swh/core/tests/test_config.py
+++ b/swh/core/tests/test_config.py
@@ -326,9 +326,9 @@ def test_merge_config_type_error():
             config.merge_configs({"a": {}}, {"a": v})
 
 
-def test_load_from_envvar_no_environment_var_swh_config_filename_set():
+def test_load_from_envvar_no_environment_var_swh_config_filename_set(monkeypatch):
     """Without SWH_CONFIG_FILENAME set, load_from_envvar raises"""
-
+    monkeypatch.delenv("SWH_CONFIG_FILENAME", raising=False)
     with pytest.raises(AssertionError, match="SWH_CONFIG_FILENAME environment"):
         config.load_from_envvar()