Skip to content

Commit

Permalink
fix(configuration): strip whitespaces when reading .testcontainers.pr…
Browse files Browse the repository at this point in the history
…operties (testcontainers#474)

## What does this PR do?

Strip whitespaces from key and value after reading
`~/.testcontainers.properties`. The way TCD writes this file, the `=`
will be surrounded by whitespaces, e.g.:

```
kiview@kay ~ % cat .testcontainers.properties
tc.host = tcp://127.0.0.1:59499
testcontainers.reuse.enable = true
```

## Why is it important?

Adds Plug&Play support for Testcontainers Desktop and Testcontainers
Cloud.

## How to test this PR

Run any kind of tests that involve creating and starting containers,
while Testcontainers Desktop is running. Testcontainers Desktop should
be used and hence started containers can be seen in the Testcontainers
Cloud dashboard.
  • Loading branch information
kiview authored Mar 14, 2024
1 parent ca65a91 commit ade144e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/testcontainers/core/docker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def read_tc_properties() -> dict[str, str]:
tuples = []
with open(file) as contents:
tuples = [line.split("=") for line in contents.readlines() if "=" in line]
settings = {**settings, **{item[0]: item[1] for item in tuples}}
settings = {**settings, **{item[0].strip(): item[1].strip() for item in tuples}}
return settings


Expand Down

0 comments on commit ade144e

Please sign in to comment.