Skip to content

feat(main): Migrate to src layout#1045

Merged
alexanderankin merged 29 commits into
testcontainers:mainfrom
CarliJoy:move_to_src
Jun 6, 2026
Merged

feat(main): Migrate to src layout#1045
alexanderankin merged 29 commits into
testcontainers:mainfrom
CarliJoy:move_to_src

Conversation

@CarliJoy
Copy link
Copy Markdown
Contributor

@CarliJoy CarliJoy commented Jun 5, 2026

This merge requests changes the layout of testcontainers to use src layout.

Doing this some bugs surfaced that were fixed.
Also some minor improvement were made on the way. Hopefully everything is still readable.
I also used the opportunity to clean up the ruff config a bit and activate it again for tests.

Also the complete package is now typed and mypy passes 🎉

Closes #720
Closes #968
Closes #305

Please don't squash this mr or the commit history will be hard to understand.

CarliJoy and others added 25 commits June 5, 2026 23:59
- removed some now deprecated make entrypoints/scripts
Some related errors were fixed:

- ryuk: increase container removal timeout 30s -> 60s; Docker is slower
  to clean up when many containers are running concurrently
- socat: helloworld container had no wait strategy, causing
  ConnectionResetError when socat forwarded requests before the HTTP
  server was ready
- db2/mssql: mark with xdist_group to prevent parametrized versions
  from running in parallel; concurrent instances caused OOM kills and
  resource exhaustion

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- use new driver: no workaround required anymore
- set protocol_version=5 for Cassandra 4.x to suppress negotiation warnings

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Version bump 1.24.5 -> 1.28.4
- Add dedicated RFC1918 network (10.10.10.0/24) so Weaviate's memberlist
  gossip always advertises a private IP
- Switch container config from CLI args to env vars
- Replace _connect() + wait_container_is_ready with HttpWaitStrategy
- Use DockerContainer as base class instead of DbContainer
- fix(image): assert _image not None in get_wrapped_image()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace manual _connect()/_healthcheck() with CompositeWaitStrategy.
Also fixes a bug where _healthcheck() was called twice in start()
(once inside _connect() and once directly). Move command into __init__
to remove the start() override entirely.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30s was not enough for the JVM to emit the startup log message under
load when running the full test suite in parallel.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Keycloak 26+ enforces SSL by default even for localhost, causing client
connections over plain HTTP to fail. Disable it via kcadm.sh post-start.
Also add user_realm_name to get_client() kwargs to fix authentication
against the master realm.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Passing tmpfs as a Docker kwarg dict is no longer supported in the new
container API. Use the dedicated with_tmpfs_mount() method instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Calling sftp_container.start() inside a with block double-starts the
container (the context manager already calls start()). Also add
allow_agent=False and look_for_keys=False to paramiko connect() calls
to prevent the SSH client from picking up ambient keys/agents from the
test environment, which caused intermittent auth failures.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…index

add_hash_index() was removed in python-arango >= 8; persistent indexes
are the recommended replacement and cover the same use case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Non-durable queues are dropped on broker restart. Declaring the test
queue as durable matches real-world usage and prevents flaky failures
when the broker isn't fully settled.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pytest --import-mode=importlib requires explicit relative imports for
local helper modules; the bare import worked by accident under the old
import mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace manual _connect() + @wait_container_is_ready(OSError) with
PortWaitStrategy. Since targets are registered after __init__ via
with_target(), the strategy is applied in start() just before
delegating to super().

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- fix all typing errors and asserts in tests
- improved type hints for main methods like docker.run.
We want autoformat and the https://docs.astral.sh/ruff/rules/#flake8-pytest-style-pt  checks for tests.
If some rules are annyoing, just disable them with per-file-ignores.
Also ruff is very conservative in it's fixes. so just keep the defaults
Make it based on python. Simplify the module names and add a test that enforces src, tests, pyproject.toml extra and docs are in sync.
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

❌ Patch coverage is 90.00000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.94%. Comparing base (65c0146) to head (ca0c8ef).

Files with missing lines Patch % Lines
src/testcontainers/core/container.py 86.84% 3 Missing and 2 partials ⚠️
src/testcontainers/core/image.py 81.81% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1045      +/-   ##
==========================================
+ Coverage   83.29%   85.94%   +2.64%     
==========================================
  Files          16       16              
  Lines        1754     1750       -4     
  Branches      193      196       +3     
==========================================
+ Hits         1461     1504      +43     
+ Misses        236      186      -50     
- Partials       57       60       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pyproject.toml
Comment on lines 377 to 379
[[tool.mypy.overrides]]
module = ["docker.*"]
module = ["pika.*"]
ignore_missing_imports = true
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun fact: Docker was (probably) never really used to type check against, because its stubs were missing.

At the same time it is the most important library for this project ;-)

Copy link
Copy Markdown
Member

@alexanderankin alexanderankin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets get this over with 👍

@alexanderankin alexanderankin merged commit 592c6d1 into testcontainers:main Jun 6, 2026
141 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request: change repo layout (to src based layout) Feature: Change to another layout [src] Mark packages as typed

2 participants