← All tasks
pythontestcontainers/testcontainers-python #774Not a task: already works

Bug: Connection mode override environment variable is not honored

envgap__testcontainers__testcontainers-python-774

01 / FAILURE SIGNATURE

As reported upstream

No identifying execution failure has been captured.
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
b574c0e0a11d57c8c56aef448292f8c2fc233078
Manifest
pyproject.toml
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

testcontainers/testcontainers-python #774 · read the original issue
**Describe the bug**

The `testcontainers.core.config` module defines a `get_user_overridden_connection_mode` function that reads the `TESTCONTAINERS_CONNECTION_MODE` environment variable. This _looks_ as though it should be used to initialize the `connection_mode_override` member of the `testcontainers_config` object, but is actually unused.

I guess this might be intentional, but it would seem useful to be able to easily control the connection mode from the environment.

**To Reproduce**

```python
import os
os.environ["TESTCONTAINERS_CONNECTION_MODE"] = "bridge_ip"
import testcontainers.core.config as config
assert config.testcontainers_config.connection_mode_override == config.ConnectionMode.bridge_ip
```

**Runtime environment**

```bash
$ uname -a
Linux *** 6.8.0-52-generic #53-Ubuntu SMP PREEMPT_DYNAMIC Sat Jan 11 00:06:25 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 3.9.2
$ pip freeze
certifi==2025.1.31
charset-normalizer==3.4.1
docker==7.1.0
idna==3.10
python-dotenv==1.0.1
requests==2.32.3
testcontainers==4.9.1
typing_extensions==4.12.2
urllib3==2.3.0
wrapt==1.17.2
```
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]