diff --git a/tests/by_image/docker-stacks-foundation/test_user_options.py b/tests/by_image/docker-stacks-foundation/test_user_options.py index dedb36f7..635cb709 100644 --- a/tests/by_image/docker-stacks-foundation/test_user_options.py +++ b/tests/by_image/docker-stacks-foundation/test_user_options.py @@ -175,11 +175,10 @@ def test_set_uid(container: TrackedContainer) -> None: Additionally, verify that "--group-add=users" is suggested in a warning to restore write access. """ + # This test needs to have tty disabled, the reason is explained here: + # https://github.com/jupyter/docker-stacks/pull/2260#discussion_r2008821257 logs = container.run_and_wait( - timeout=5, - no_warnings=False, - user="1010", - command=["id"], + timeout=5, no_warnings=False, user="1010", command=["id"], tty=False ) assert "uid=1010(jovyan) gid=0(root)" in logs warnings = TrackedContainer.get_warnings(logs) diff --git a/tests/utils/tracked_container.py b/tests/utils/tracked_container.py index 5ae1bbd0..a6dae56d 100644 --- a/tests/utils/tracked_container.py +++ b/tests/utils/tracked_container.py @@ -45,8 +45,10 @@ class TrackedContainer: extending and/or overriding key/value pairs passed to the constructor """ LOGGER.info(f"Running {self.image_name} with args {kwargs} ...") + default_kwargs = {"detach": True, "tty": True} + final_kwargs = default_kwargs | kwargs self.container = self.docker_client.containers.run( - self.image_name, **kwargs, detach=True + self.image_name, **final_kwargs ) def get_logs(self) -> str: @@ -64,7 +66,9 @@ class TrackedContainer: assert self.container is not None container = self.container LOGGER.info(f"Running cmd: `{cmd}` on container: {container.name}") - exec_result = container.exec_run(cmd, **kwargs) + default_kwargs = {"tty": True} + final_kwargs = default_kwargs | kwargs + exec_result = container.exec_run(cmd, **final_kwargs) output = exec_result.output.decode().rstrip() assert isinstance(output, str) LOGGER.info(f"Command output: {output}")