def test_docker_container_with_env_file():
    """Test that environment variables can be loaded from a file"""
    with tempfile.TemporaryDirectory() as temp_directory:
        env_file_path = Path(temp_directory) / "env_file"
        with open(env_file_path, "w") as f:
            f.write(
                """
                TEST_ENV_VAR=hello
                NUMBER=123
                DOMAIN=example.org
                ADMIN_EMAIL=admin@${DOMAIN}
                ROOT_URL=${DOMAIN}/app
                """
            )
        container = DockerContainer("alpine").with_command("tail -f /dev/null")  # Keep the container running
        container.with_env_file(env_file_path)  # Load the environment variables from the file
        with container:
            output = container.exec("env").output.decode("utf-8").strip()
            assert "TEST_ENV_VAR=hello" in output
            assert "NUMBER=123" in output
            assert "DOMAIN=example.org" in output
            assert "ADMIN_EMAIL=admin@example.org" in output
            assert "ROOT_URL=example.org/app" in output
            print(output)
Test that environment variables can be loaded from a file
core/tests/test_core.py