| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Adds a dedicated test module for DockerContainer.exec covering the str and list[str] forms it already accepts. The interesting part is the negative pins: docker-py tokenizes a str command with shlex.split and never invokes a shell, so pipes, redirects, and $VAR expansion are passed through literally. That sharp edge was previously untested; nailing it down makes any future move toward native shell-mode a visible, intentional diff.
Adds a frozen ExecConfig dataclass mirroring testcontainers-java's ExecConfig (command, user, environment, workdir) plus privileged. It is a deliberately backend-agnostic carrier: only command is required and every other field defaults to None/False, so it never encodes docker-py's conventions. All docker-py coercion is confined to the pure _exec_run_kwargs() seam at the I/O boundary -- the empty-string user sentinel, str(workdir) so pathlib.Path is accepted, and verbatim command forwarding (docker-py does its own shlex tokenization). exec() now accepts str | list[str] | ExecConfig and funnels all three through that single path. The config->kwargs logic and the exec() normalization branch are covered by hermetic unit tests (no daemon required); behavioral verification against a real container follows separately.
Exercises the new fields against a real alpine container: workdir (str and pathlib.Path) via pwd, environment via env, user via whoami (root vs nobody), and privileged by reading CapEff from procfs -- a privileged exec gets the full capability set, so its effective mask strictly exceeds the default exec's even on an unprivileged container.
Rewrites the executing-commands guide around the real surface: exec() taking str | list[str] | ExecConfig, the bytes-valued result, and the user / environment / workdir / privileged options via ExecConfig. Adds the str-is-tokenized-not-shell-interpreted caveat that the old environment example silently got wrong (echo $VAR never expanded). Also removes sections that documented APIs the library never had: GenericContainer (the generic container is DockerContainer), exec_interactive, and the timeout= / tty= exec parameters. The TTY section is gone entirely; the interactive and timeout sections had no real ExecConfig equivalent to map to.
|
didnt realize it was just for the exec method. that is pretty minor so i think its fine |
Sorry, something went wrong.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1050 +/- ##
==========================================
+ Coverage 85.96% 86.15% +0.19%
==========================================
Files 16 16
Lines 1753 1763 +10
Branches 196 196
==========================================
+ Hits 1507 1519 +12
+ Misses 186 185 -1
+ Partials 60 59 -1
|
Sorry, something went wrong.
🤖 I have created a release *beep* *boop* --- ## [4.15.0-rc4](testcontainers-v4.15.0-rc3...testcontainers-v4.15.0-rc4) (2026-06-11) ### Features * extended configuration options for container.exec method ([#1050](#1050)) ([7dee471](7dee471)) * **main:** enable typing for complete package ([237be27](237be27)) * **main:** make legacy imports available with deprecation notice ([ab6cca8](ab6cca8)) * **test:** start working on parallel-running tests (WIP!) ([2d24429](2d24429)) ### Bug Fixes * **arangodb:** replace deprecated add_hash_index with add_persistent_index ([50bb202](50bb202)) * **aws:** wrong path of test ([38089b0](38089b0)) * **ci:** correct coverage paths ([b21eccd](b21eccd)) * **ci:** fix community test selection ([5287fc8](5287fc8)) * **ci:** ignore [@overload](https://github.com/overload) in coverage ([592c6d1](592c6d1)) * **ci:** ignore TYPE_CHECKING block in coverage ([3bdc561](3bdc561)) * **core/registry:** use relative import for _LocalRegistryContainer ([961e3d1](961e3d1)) * **core:** make is_podman respect resolved docker host ([#1048](#1048)) ([6018da3](6018da3)) * **docs:** update docs reflecting new structure ([9427055](9427055)) * **doctests:** Ensure paths are correct ([f777673](f777673)) * **k3s:** replace tmpfs dict kwarg with with_tmpfs_mount() ([4d1da0c](4d1da0c)) * **keycloak:** disable SSL requirement for master realm after start ([2a85595](2a85595)) * **main:** adopt ci to new src structure ([dae421d](dae421d)) * **main:** adopt imports to new structure ([9155677](9155677)) * **rabbitmq:** declare queue as durable ([2622736](2622736)) * **ruff:** add **/*_example.py to per-file-ignores for T201 ([01dbd16](01dbd16)) * **sftp:** remove redundant start() calls and fix SSH connection options ([54cef56](54cef56)) * **trino:** increase default startup timeout from 30s to 60s ([2940501](2940501)) * **weaviate:** update and fix module ([5dd2aa1](5dd2aa1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: David Ankin <daveankin@gmail.com>
| Back | FazBrowse Home | New Git URL |
The branch adds the ExecConfig struct (patterned on the Java implementation of the same feature) and includes it as a valid input for DockerContainer.exec(). This allows setting the running user, working directory, environment variables, and privileged mode. Other features become easy extensions of the interface.
Also included in the branch: