Skip to content

Commit d749fc6

Browse files
docs: missing compose html from old docs (#776)
fix #763 --------- Co-authored-by: Roy Moore <[email protected]>
1 parent b816762 commit d749fc6

File tree

7 files changed

+46
-19
lines changed

7 files changed

+46
-19
lines changed

compose.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Docker Compose
2+
==============
3+
4+
Docker compose is described in :ref:`Testcontainers Core`.

conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"sphinx.ext.doctest",
3434
"sphinx.ext.intersphinx",
3535
"sphinx.ext.napoleon",
36+
"sphinx.ext.autosectionlabel",
3637
]
3738

3839
# Configure autodoc to avoid excessively long fully-qualified names.

core/README.rst

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,28 @@ Testcontainers Core
33

44
:code:`testcontainers-core` is the core functionality for spinning up Docker containers in test environments.
55

6-
.. autoclass:: testcontainers.core.container.DockerContainer
7-
:members: with_bind_ports, with_exposed_ports
6+
.. automodule:: testcontainers.core.container
7+
:members:
8+
:undoc-members:
9+
10+
.. autoclass:: testcontainers.core.network.Network
11+
:members:
812

9-
.. note::
10-
When using `with_bind_ports` or `with_exposed_ports`
11-
you can specify the port in the following formats: :code:`{private_port}/{protocol}`
13+
.. autoclass:: testcontainers.core.image.DockerImage
1214

13-
e.g. `8080/tcp` or `8125/udp` or just `8080` (default protocol is tcp)
15+
.. autoclass:: testcontainers.core.generic.DbContainer
1416

15-
For legacy reasons, the port can be an *integer*
17+
.. raw:: html
1618

17-
.. autoclass:: testcontainers.core.image.DockerImage
19+
<hr>
1820

19-
.. autoclass:: testcontainers.core.generic.DbContainer
21+
Compose
22+
-------
2023

21-
.. autoclass:: testcontainers.core.network.Network
24+
It is also possible to use Docker Compose functionality:
25+
26+
.. automodule:: testcontainers.compose.compose
27+
:members:
2228

2329
.. raw:: html
2430

core/testcontainers/compose/compose.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ class DockerCompose:
154154
155155
>>> from testcontainers.compose import DockerCompose
156156
157-
>>> compose = DockerCompose("compose/tests", compose_file_name="docker-compose-4.yml",
157+
>>> compose = DockerCompose("core/tests/compose_fixtures/basic", compose_file_name="hello.yaml",
158158
... pull=True)
159159
>>> with compose:
160160
... stdout, stderr = compose.get_logs()
161-
>>> b"Hello from Docker!" in stdout
161+
>>> "Hello from Docker!" in stdout
162162
True
163163
164164
.. code-block:: yaml
@@ -197,7 +197,7 @@ def docker_compose_command(self) -> list[str]:
197197
Returns command parts used for the docker compose commands
198198
199199
Returns:
200-
cmd: Docker compose command parts.
200+
list[str]: Docker compose command parts.
201201
"""
202202
return self.compose_command_property
203203

@@ -263,8 +263,8 @@ def get_logs(self, *services: str) -> tuple[str, str]:
263263
:param services: which services to get the logs for (or omit, for all)
264264
265265
Returns:
266-
stdout: Standard output stream.
267-
stderr: Standard error stream.
266+
str: stdout: Standard output stream.
267+
str: stderr: Standard error stream.
268268
"""
269269
logs_cmd = [*self.compose_command_property, "logs", *services]
270270

@@ -364,15 +364,15 @@ def exec_in_container(
364364
365365
Args:
366366
service_name: Name of the docker compose service to run the command in.
367-
command: Command to execute.
367+
command: Command to execute.
368368
369369
:param service_name: specify the service name
370370
:param command: the command to run in the container
371371
372372
Returns:
373-
stdout: Standard output stream.
374-
stderr: Standard error stream.
375-
exit_code: The command's exit code.
373+
str: stdout: Standard output stream.
374+
str: stderr: Standard error stream.
375+
int: exit_code: The command's exit code.
376376
"""
377377
if not service_name:
378378
service_name = self.get_container().Service

core/testcontainers/core/container.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ def get_wrapped_container(self) -> "Container":
250250
return self._container
251251

252252
def get_docker_client(self) -> DockerClient:
253+
"""
254+
:meta private:
255+
"""
253256
return self._docker
254257

255258
def get_logs(self) -> tuple[bytes, bytes]:
@@ -268,6 +271,10 @@ def _configure(self) -> None:
268271

269272

270273
class Reaper:
274+
"""
275+
:meta private:
276+
"""
277+
271278
_instance: "Optional[Reaper]" = None
272279
_container: Optional[DockerContainer] = None
273280
_socket: Optional[socket] = None
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
services:
2+
hello:
3+
image: alpine:latest
4+
init: true
5+
command:
6+
- sh
7+
- -c
8+
- 'while true; do echo "Hello from Docker!"; sleep 1; done'

index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ testcontainers-python facilitates the use of Docker containers for functional an
1616
:maxdepth: 1
1717

1818
core/README
19+
compose
1920
modules/index
2021

2122
Getting Started

0 commit comments

Comments
 (0)