testcontainers / testcontainers/testcontainers-python

Feature: other ways to configure than the `.testcontainers.properties` in Home

Open
#904 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

🚀 enhancement
Dominant language
Python
Stars
2.3k
Forks
386
Avg merge
4h 40m
Merged PRs (30d)
1

Description

What are you trying to do?

I want to run my tests, which rely on Test Containers, on my CI. But I don't have the rights to edit the runner's profile home directory (read-only). So I would like to be able to provide a .testcontainers.properties elsewhere, or from environment variables.

This seems to be possible in the Java version, based on this docstring in the Python version :

Read the .testcontainers.properties for settings. (see the Java implementation for details)
Currently we only support the ~/.testcontainers.properties but may extend to per-project variables later.
:return: the merged properties from the sources.

But (see below) it relies on the Java classpath , and I don't think it would be relevant to use the pythonpath for that on Python's side.
So I am unsure how to proceed towards per-project (or arbitrarily-located) properties files.

But using environment variables should be straightforward.

Why should it be done this way?

Parity with Java implementation, and flexibility.

Other references:

From the Java documentation :

The configuration will be loaded from multiple locations. Properties are considered in the following order:

  1. Environment variables
  2. .testcontainers.properties in user's home folder. Example locations:
  • Linux: /home/myuser/.testcontainers.properties
  • Windows: C:/Users/myuser/.testcontainers.properties
  • macOS: /Users/myuser/.testcontainers.properties
  1. testcontainers.properties on the classpath.
    Note that when using environment variables, configuration property names should be set in upper case with underscore separators, preceded by TESTCONTAINERS_ - e.g. checks.disable becomes TESTCONTAINERS_CHECKS_DISABLE.

Next steps

Does it seem relevant to you ? Would you be interested I contribute a PR for it ?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with testcontainers/core/config.py, particularly the configuration-loading behavior referenced in the issue, and compare it with the Java configuration order in the linked documentation. Define how environment variables and an alternate properties location should interact with the home-file settings. Done means the supported configuration sources and their precedence are documented and covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.