diff --git a/tests/containers/base_image_test.py b/tests/containers/base_image_test.py index 63a021660d..3a6a2f7283 100644 --- a/tests/containers/base_image_test.py +++ b/tests/containers/base_image_test.py @@ -163,6 +163,23 @@ def test_oc_command_runs_fake_fips(self, image: str, subtests: pytest_subtests.S finally: docker_utils.NotebookContainer(container).stop(timeout=0) + def test_pip_install_cowsay_runs(self, image: str): + """Checks that the Python virtualenv in the image is writable.""" + container = testcontainers.core.container.DockerContainer(image=image, user=23456, group_add=[0]) + container.with_command("/bin/sh -c 'sleep infinity'") + try: + container.start() + + ecode, output = container.exec(["python3", "-m", "pip", "install", "cowsay"]) + logging.debug(output.decode()) + assert ecode == 0 + + ecode, output = container.exec(["python3", "-m", "cowsay", "--text", "Hello world"]) + logging.debug(output.decode()) + assert ecode == 0 + finally: + docker_utils.NotebookContainer(container).stop(timeout=0) + def encode_python_function_execution_command_interpreter(python: str, function: Callable[..., Any], *args: list[Any]) -> list[str]: """Returns a cli command that will run the given Python function encoded inline.