diff --git a/base-notebook/test/test_container_options.py b/base-notebook/test/test_container_options.py index ca8b61fe..8e49ee41 100644 --- a/base-notebook/test/test_container_options.py +++ b/base-notebook/test/test_container_options.py @@ -240,12 +240,13 @@ def test_container_not_delete_bind_mount(container, tmp_path): assert len(list(tmp_path.iterdir())) == 1 -def test_jupyter_env_vars_to_unset_as_root(container): +@pytest.mark.parametrize("enable_root", [False, True]) +def test_jupyter_env_vars_to_unset_as_root(container, enable_root): """Environment variables names listed in JUPYTER_ENV_VARS_TO_UNSET should be unset in the final environment.""" + root_args = {"user": "root"} if enable_root else {} c = container.run( tty=True, - user="root", environment=[ "JUPYTER_ENV_VARS_TO_UNSET=SECRET_ANIMAL,UNUSED_ENV,SECRET_FRUIT", "FRUIT=bananas", @@ -258,6 +259,7 @@ def test_jupyter_env_vars_to_unset_as_root(container): "-c", "echo I like $FRUIT and ${SECRET_FRUIT:-stuff}, and love ${SECRET_ANIMAL:-to keep secrets}!", ], + **root_args, ) rv = c.wait(timeout=10) assert rv == 0 or rv["StatusCode"] == 0