FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

docs: missing compose html from old docs by alexanderankin · Pull Request #776 · testcontainers/testcontainers-python · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) .rst  (3) .yaml  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions compose.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Docker Compose
==============

Docker compose is described in :ref:`Testcontainers Core`.
1 change: 1 addition & 0 deletions conf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.napoleon",
"sphinx.ext.autosectionlabel",
]

# Configure autodoc to avoid excessively long fully-qualified names.
Expand Down
26 changes: 16 additions & 10 deletions core/README.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,28 @@ Testcontainers Core

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

.. autoclass:: testcontainers.core.container.DockerContainer
:members: with_bind_ports, with_exposed_ports
.. automodule:: testcontainers.core.container
:members:
:undoc-members:

.. autoclass:: testcontainers.core.network.Network
:members:

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

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

For legacy reasons, the port can be an *integer*
.. raw:: html

.. autoclass:: testcontainers.core.image.DockerImage
<hr>

.. autoclass:: testcontainers.core.generic.DbContainer
Compose
-------

.. autoclass:: testcontainers.core.network.Network
It is also possible to use Docker Compose functionality:

.. automodule:: testcontainers.compose.compose
:members:

.. raw:: html

Expand Down
18 changes: 9 additions & 9 deletions core/testcontainers/compose/compose.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ class DockerCompose:

>>> from testcontainers.compose import DockerCompose

>>> compose = DockerCompose("compose/tests", compose_file_name="docker-compose-4.yml",
>>> compose = DockerCompose("core/tests/compose_fixtures/basic", compose_file_name="hello.yaml",
... pull=True)
>>> with compose:
... stdout, stderr = compose.get_logs()
>>> b"Hello from Docker!" in stdout
>>> "Hello from Docker!" in stdout
True

.. code-block:: yaml
Expand Down Expand Up @@ -191,7 +191,7 @@ def docker_compose_command(self) -> list[str]:
Returns command parts used for the docker compose commands

Returns:
cmd: Docker compose command parts.
list[str]: Docker compose command parts.
"""
return self.compose_command_property

Expand Down Expand Up @@ -257,8 +257,8 @@ def get_logs(self, *services: str) -> tuple[str, str]:
:param services: which services to get the logs for (or omit, for all)

Returns:
stdout: Standard output stream.
stderr: Standard error stream.
str: stdout: Standard output stream.
str: stderr: Standard error stream.
"""
logs_cmd = [*self.compose_command_property, "logs", *services]

Expand Down Expand Up @@ -358,15 +358,15 @@ def exec_in_container(

Args:
service_name: Name of the docker compose service to run the command in.
command: Command to execute.
command: Command to execute.

:param service_name: specify the service name
:param command: the command to run in the container

Returns:
stdout: Standard output stream.
stderr: Standard error stream.
exit_code: The command's exit code.
str: stdout: Standard output stream.
str: stderr: Standard error stream.
int: exit_code: The command's exit code.
"""
if not service_name:
service_name = self.get_container().Service
Expand Down
7 changes: 7 additions & 0 deletions core/testcontainers/core/container.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def get_wrapped_container(self) -> "Container":
return self._container

def get_docker_client(self) -> DockerClient:
"""
:meta private:
"""
return self._docker

def get_logs(self) -> tuple[bytes, bytes]:
Expand All @@ -253,6 +256,10 @@ def _configure(self) -> None:


class Reaper:
"""
:meta private:
"""

_instance: "Optional[Reaper]" = None
_container: Optional[DockerContainer] = None
_socket: Optional[socket] = None
Expand Down
8 changes: 8 additions & 0 deletions core/tests/compose_fixtures/basic/hello.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
services:
hello:
image: alpine:latest
init: true
command:
- sh
- -c
- 'while true; do echo "Hello from Docker!"; sleep 1; done'
1 change: 1 addition & 0 deletions index.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ testcontainers-python facilitates the use of Docker containers for functional an
:maxdepth: 1

core/README
compose
modules/index

Getting Started
Expand Down

Back | FazBrowse Home | New Git URL