pytest-docker-compose-v2 0.1.2__tar.gz → 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. pytest_docker_compose_v2-0.2.0/.devcontainer/Dockerfile +76 -0
  2. pytest_docker_compose_v2-0.2.0/.devcontainer/devcontainer.json +80 -0
  3. pytest_docker_compose_v2-0.2.0/.github/workflows/release.yaml +40 -0
  4. pytest_docker_compose_v2-0.2.0/.github/workflows/test.yaml +48 -0
  5. pytest_docker_compose_v2-0.2.0/.gitignore +123 -0
  6. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/PKG-INFO +22 -24
  7. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/README.md +11 -16
  8. pytest_docker_compose_v2-0.2.0/pyproject.toml +125 -0
  9. pytest_docker_compose_v2-0.2.0/pytest_docker_compose/__init__.py +1 -0
  10. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/pytest_docker_compose/plugin.py +14 -2
  11. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/my_network/a_buildable_container/an_api.py +23 -22
  12. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/test_function_scoping_fixtures.py +0 -2
  13. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/test_module_scoping_fixtures.py +0 -2
  14. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/test_multiple_compose_files.py +0 -2
  15. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/test_wrong_scoping.py +0 -2
  16. pytest_docker_compose_v2-0.2.0/uv.lock +976 -0
  17. pytest-docker-compose-v2-0.1.2/pyproject.toml +0 -101
  18. pytest-docker-compose-v2-0.1.2/pytest_docker_compose/__init__.py +0 -1
  19. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/LICENSE +0 -0
  20. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/my_network/a_buildable_container/Dockerfile +0 -0
  21. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/my_network/a_buildable_container/requirements.txt +0 -0
  22. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/my_network/docker-compose.yml +0 -0
  23. {pytest-docker-compose-v2-0.1.2 → pytest_docker_compose_v2-0.2.0}/tests/pytest_docker_compose_tests/my_network/extra-service.yml +0 -0
@@ -0,0 +1,76 @@
1
+ FROM python:3.11.8-bookworm
2
+
3
+ ARG DEBIAN_FRONTEND=noninteractive
4
+ ARG UID=1000
5
+ ARG GID=1000
6
+ ARG DEV_USER=dev
7
+ ARG BUILD_DIR=/tmp/build
8
+
9
+ ENV VIRTUAL_ENV=/venv
10
+ ENV LC_ALL en_US.UTF-8
11
+ ENV LANG en_US.UTF-8
12
+ ENV LANGUAGE en_US.UTF-8
13
+
14
+ RUN apt-get update \
15
+ && apt-get install -yq --no-install-recommends \
16
+ # useful OS packages
17
+ sudo \
18
+ locales \
19
+ locales-all \
20
+ build-essential \
21
+ openssh-client \
22
+ rsync \
23
+ iputils-ping \
24
+ wget \
25
+ git \
26
+ ripgrep \
27
+ unzip \
28
+ curl \
29
+ vim \
30
+ bash-completion \
31
+ man-db \
32
+ less \
33
+ # Docker CE CLI and other packages
34
+ apt-transport-https \
35
+ ca-certificates \
36
+ && rm -rf /var/lib/apt/lists/* \
37
+ && update-ca-certificates
38
+
39
+ RUN addgroup --gid ${GID} ${DEV_USER} \
40
+ && adduser --disabled-password --gecos '' --uid ${UID} --gid ${GID} ${DEV_USER} \
41
+ && mkdir -p /etc/sudoers.d \
42
+ && echo ${DEV_USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${DEV_USER} \
43
+ && chmod 0440 /etc/sudoers.d/${DEV_USER} \
44
+ && mkdir -p /home/${DEV_USER} \
45
+ && mkdir -p /home/${DEV_USER}/.vscode-server/extensions \
46
+ && mkdir -p /home/${DEV_USER}/.vscode-server-insiders/extensions \
47
+ && chown -R ${DEV_USER}:${DEV_USER} /home/${DEV_USER}
48
+
49
+ # install node
50
+ RUN curl -sL https://deb.nodesource.com/setup_18.x | bash -
51
+ RUN apt-get update \
52
+ && apt-get install -yq --no-install-recommends \
53
+ nodejs \
54
+ && rm -rf /var/lib/apt/lists/* \
55
+ && update-ca-certificates
56
+
57
+ # install devcontainer cli tool so we can build and push devcontainer from itself
58
+ RUN npm install -g @devcontainers/cli
59
+ RUN mkdir ${VIRTUAL_ENV} && chown ${UID}:${GID} ${VIRTUAL_ENV}
60
+
61
+ # install uv
62
+ COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
63
+
64
+ USER ${DEV_USER}
65
+
66
+ ENV PATH "/home/${DEV_USER}/.local/bin:${PATH}"
67
+
68
+ # install dependencies into virtualenv
69
+ WORKDIR ${BUILD_DIR}
70
+ RUN uv venv ${VIRTUAL_ENV}
71
+ COPY pyproject.toml uv.lock README.md ${BUILD_DIR}
72
+ RUN uv sync --locked
73
+
74
+ WORKDIR /workspace
75
+
76
+ LABEL org.opencontainers.image.source https://github.com/radusuciu/pytest-docker-compose-v2
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "pytest docker compose v2 Development",
3
+ "build": {
4
+ "dockerfile": "Dockerfile",
5
+ "context": "${localWorkspaceFolder}"
6
+ },
7
+ // needed because of the interaction between the devcontainer
8
+ // the test docker compose project, and the hostname reported by
9
+ // docker inspect in the tests in the PortConfig.
10
+ // the hostname is 0.0.0.0 and cannot be reached by the test code
11
+ // unless the devcontainer is on the host network. I've tried, among
12
+ // many othe permutations, putting the devcontainer on the same
13
+ // externally created network as the test containers but that did
14
+ // not work
15
+ "runArgs": [
16
+ "--network=host"
17
+ ],
18
+ "workspaceFolder": "/workspace",
19
+ "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
20
+ "mounts": [
21
+ {
22
+ "source": "/var/run/docker.sock",
23
+ "target": "/var/run/docker.sock",
24
+ "type": "bind"
25
+ }
26
+ ],
27
+ // Set *default* container specific settings.json values on container create.
28
+ "customizations": {
29
+ "vscode": {
30
+ "extensions": [
31
+ "ms-python.python",
32
+ "charliermarsh.ruff",
33
+ "ms-azuretools.vscode-docker",
34
+ "eamodio.gitlens",
35
+ "Gruntfuggly.todo-tree",
36
+ "be5invis.toml",
37
+ "GitHub.vscode-github-actions",
38
+ "GitHub.copilot",
39
+ "GitHub.vscode-pull-request-github"
40
+ ],
41
+ "settings": {
42
+ "#terminal.integrated.defaultProfile.linux#": "/bin/bash",
43
+ "python.defaultInterpreterPath": "/venv/bin/python",
44
+ "python.terminal.activateEnvironment": true,
45
+ "python.testing.unittestEnabled": false,
46
+ "python.testing.nosetestsEnabled": false,
47
+ "python.testing.pytestEnabled": true,
48
+ "ruff.organizeImports": true,
49
+ "[python]": {
50
+ "editor.codeActionsOnSave": {
51
+ "source.organizeImports": "always"
52
+ },
53
+ "editor.defaultFormatter": "charliermarsh.ruff",
54
+ "editor.formatOnSave": true
55
+ },
56
+ "[dockerfile]": {
57
+ "editor.formatOnSave": false
58
+ },
59
+ "dev.containers.dockerCredentialHelper": false
60
+ }
61
+ }
62
+ },
63
+ "features": {
64
+ "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
65
+ "ghcr.io/devcontainers/features/github-cli:1": {}
66
+ },
67
+ "remoteEnv": {
68
+ // Pass in the host directory for Docker mount commands from inside the container
69
+ "HOST_PROJECT_PATH": "${localWorkspaceFolder}",
70
+ "VIRTUAL_ENV": "/venv",
71
+ "PATH": "${containerEnv:PATH}:/venv/bin",
72
+ "EDITOR": "code --wait",
73
+ "VISUAL": "code --wait",
74
+ "GIT_EDITOR": "code --wait"
75
+ },
76
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
77
+ // Left empty because this is handled by docker compose for individual services,
78
+ // use this only for additional ports not needed by those services (e.g. ssh)
79
+ "forwardPorts": []
80
+ }
@@ -0,0 +1,40 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*.*.*'
7
+
8
+ jobs:
9
+ build-and-publish:
10
+ runs-on: ubuntu-latest
11
+ environment: pypi-publish
12
+ permissions:
13
+ # for creating github release
14
+ contents: write
15
+ # for trusted publishing
16
+ id-token: write
17
+ steps:
18
+ - name: Check out repository
19
+ uses: actions/checkout@v5
20
+ - name: Set up uv
21
+ uses: astral-sh/setup-uv@v7
22
+ with:
23
+ enable-cache: true
24
+ python-version: '3.13'
25
+
26
+ - name: Install dependencies
27
+ run: uv sync
28
+ - name: Run tests
29
+ run: uv run pytest
30
+ - name: Create GitHub release
31
+ uses: softprops/action-gh-release@v1
32
+ with:
33
+ name: Release ${{ github.ref }}
34
+ tag_name: ${{ github.ref }}
35
+ draft: false
36
+ prerelease: false
37
+ - name: Build package
38
+ run: uv build
39
+ - name: Publish to PyPI
40
+ run: uv publish
@@ -0,0 +1,48 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - develop
8
+ pull_request:
9
+ workflow_dispatch:
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
18
+ pytest-version: ['7', '8', '9']
19
+ steps:
20
+ - name: Check out repository
21
+ uses: actions/checkout@v5
22
+ # needed because we use git describe to get a bumpver compatible GITHASH containing version
23
+ # alternatively can look at using HEXHASH instead. Note that these are purposefully not
24
+ # documented in the bumpver project, see issues/PRs for more info.
25
+ # with:
26
+ # fetch-depth: 0
27
+ - name: Set up uv
28
+ uses: astral-sh/setup-uv@v7
29
+ with:
30
+ enable-cache: true
31
+ python-version: ${{ matrix.python-version }}
32
+ - name: Install dependencies
33
+ run: uv sync
34
+ - name: Install pytest ${{ matrix.pytest-version }}
35
+ run: uv pip install "pytest>=${{ matrix.pytest-version }},<$(( ${{ matrix.pytest-version }} + 1 ))"
36
+ - name: Run tests
37
+ run: uv run pytest
38
+ # NOTE: publishing to test repository is disabled until I figure out a way to do it reliably
39
+ # this means that we need to avoid version clashes as well as local versions
40
+ # see: https://github.com/pypa/packaging.python.org/issues/804
41
+ # - name: Publish to test repository
42
+ # if: matrix.python-version == '3.11'
43
+ # run: |
44
+ # # adding the git hash to the current version so that the package
45
+ # # won't be rejected from the test repository due to version clash
46
+ # TEMP_VERSION=$(git describe | sed s/\-/\./ | sed s/\-/\+/)
47
+ # uv run bumpver update --no-commit --no-tag-commit --set-version="${TEMP_VERSION}"
48
+ # uv publish --index testpypi
@@ -0,0 +1,123 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ pip-wheel-metadata/
24
+ share/python-wheels/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+ MANIFEST
29
+
30
+ # PyInstaller
31
+ # Usually these files are written by a python script from a template
32
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
33
+ *.manifest
34
+ *.spec
35
+
36
+ # Installer logs
37
+ pip-log.txt
38
+ pip-delete-this-directory.txt
39
+
40
+ # Unit test / coverage reports
41
+ htmlcov/
42
+ .tox/
43
+ .nox/
44
+ .coverage
45
+ .coverage.*
46
+ .cache
47
+ nosetests.xml
48
+ coverage.xml
49
+ *.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+
53
+ # Translations
54
+ *.mo
55
+ *.pot
56
+
57
+ # Django stuff:
58
+ *.log
59
+ local_settings.py
60
+ db.sqlite3
61
+
62
+ # Flask stuff:
63
+ instance/
64
+ .webassets-cache
65
+
66
+ # Scrapy stuff:
67
+ .scrapy
68
+
69
+ # Sphinx documentation
70
+ docs/_build/
71
+
72
+ # PyBuilder
73
+ target/
74
+
75
+ # Jupyter Notebook
76
+ .ipynb_checkpoints
77
+
78
+ # IPython
79
+ profile_default/
80
+ ipython_config.py
81
+
82
+ # pyenv
83
+ .python-version
84
+
85
+ # pipenv
86
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
87
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
88
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
89
+ # install all needed dependencies.
90
+ #Pipfile.lock
91
+
92
+ # celery beat schedule file
93
+ celerybeat-schedule
94
+
95
+ # SageMath parsed files
96
+ *.sage.py
97
+
98
+ # Environments
99
+ .env
100
+ .venv
101
+ env/
102
+ venv/
103
+ ENV/
104
+ env.bak/
105
+ venv.bak/
106
+
107
+ # Spyder project settings
108
+ .spyderproject
109
+ .spyproject
110
+
111
+ # Rope project settings
112
+ .ropeproject
113
+
114
+ # mkdocs documentation
115
+ /site
116
+
117
+ # mypy
118
+ .mypy_cache/
119
+ .dmypy.json
120
+ dmypy.json
121
+
122
+ # Pyre type checker
123
+ .pyre/
@@ -1,11 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pytest-docker-compose-v2
3
- Version: 0.1.2
3
+ Version: 0.2.0
4
4
  Summary: Manages Docker containers during your integration tests
5
+ Project-URL: repository, https://github.com/radusuciu/pytest-docker-compose-v2
6
+ Author: Radu Suciu, Thomas Meckel, Roald Storm, Phoenix Zerin
5
7
  License: Apache
6
- Keywords: pytest,docker compose
7
- Author: Radu Suciu,Thomas Meckel,Roald Storm,Phoenix Zerin
8
- Requires-Python: >=3.9
8
+ License-File: LICENSE
9
+ Keywords: docker compose,pytest
9
10
  Classifier: Development Status :: 4 - Beta
10
11
  Classifier: Framework :: Pytest
11
12
  Classifier: Intended Audience :: Developers
@@ -16,9 +17,12 @@ Classifier: Programming Language :: Python :: 3 :: Only
16
17
  Classifier: Programming Language :: Python :: 3.10
17
18
  Classifier: Programming Language :: Python :: 3.11
18
19
  Classifier: Programming Language :: Python :: 3.12
19
- Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Programming Language :: Python :: 3.14
20
22
  Classifier: Topic :: Software Development :: Testing
21
- Project-URL: repository, https://github.com/radusuciu/pytest-docker-compose-v2
23
+ Requires-Python: >=3.10
24
+ Requires-Dist: pytest<10,>=7.2.2
25
+ Requires-Dist: python-on-whales<1,>=0.69.0
22
26
  Description-Content-Type: text/markdown
23
27
 
24
28
  [![PyPI pyversions](https://img.shields.io/pypi/pyversions/pytest-docker-compose-v2.svg)](https://pypi.python.org/pypi/pytest-docker-compose-v2/)
@@ -40,8 +44,8 @@ Make sure you have [Docker](https://docs.docker.com/get-docker/) installed.
40
44
 
41
45
  This plugin is automatically tested against the following software:
42
46
 
43
- - Python 3.9, 3.10, 3.11 and 3.12
44
- - pytest 7
47
+ - Python 3.10, 3.11, 3.12, 3.13 and 3.14
48
+ - pytest 7, 8 and 9
45
49
 
46
50
  **NOTE**: This plugin is **not** compatible with Python 2.
47
51
 
@@ -56,20 +60,17 @@ pip install pytest-docker-compose-v2
56
60
 
57
61
  ## Usage
58
62
 
59
- For performance reasons, the plugin is not enabled by default, so you must activate it manually in the tests that use it:
63
+ The plugin is automatically enabled when installed. To disable it for specific test runs, use:
60
64
 
61
- ```python
62
- pytest_plugins = ["docker_compose"]
65
+ ```shell
66
+ pytest -p no:docker_compose
63
67
  ```
64
68
 
65
-
66
- See [Installing and Using Plugins](https://docs.pytest.org/en/latest/plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file) for more information.
67
-
68
- To interact with Docker containers in your tests, use the following fixtures, these fixtures tell docker-compose to start all the services and then they can fetch the associated containers for use in a test:
69
+ To interact with Docker containers in your tests, use the following fixtures. These fixtures tell docker-compose to start all the services and then fetch the associated containers for use in a test:
69
70
 
70
71
  ### `function_scoped_container_getter`
71
72
 
72
- An object that fetches containers of the Docker `compose.container.Container` objects running during the test. The containers are fetched using `function_scoped_container_getter.get('service_name')` These containers each have an extra attribute called `network_info` added to them. This attribute has a list of `pytest_docker_compose.NetworkInfo` objects.
73
+ An object that fetches containers of the Docker `python_on_whales.Container` objects running during the test. The containers are fetched using `function_scoped_container_getter.get('service_name')` These containers each have an extra attribute called `network_info` added to them. This attribute has a list of `pytest_docker_compose.NetworkInfo` objects.
73
74
 
74
75
  This information can be used to configure API clients and other objects that will connect to services exposed by the Docker containers in your tests.
75
76
 
@@ -85,12 +86,12 @@ This information can be used to configure API clients and other objects that wil
85
86
 
86
87
  ### `docker_project`
87
88
 
88
- The `compose.project.Project` object that the containers are built from.
89
+ The `python_on_whales.DockerClient` object that the containers are built from.
89
90
  This fixture is generally only used internally by the plugin.
90
91
 
91
92
  ### Wider scoped fixtures
92
93
 
93
- To use the following fixtures please read [Use wider scoped fixtures](#use-wider-scope-fixtures)
94
+ To use the following fixtures please read [Use wider scoped fixtures](#use-wider-scoped-fixtures)
94
95
 
95
96
  - `class_scoped_container_getter`: Similar to `function_scoped_container_getter` just with a wider scope.
96
97
  - `module_scoped_container_getter`: Similar to `function_scoped_container_getter` just with a wider scope.
@@ -113,8 +114,6 @@ from urllib.parse import urljoin
113
114
  from urllib3.util.retry import Retry
114
115
  from requests.adapters import HTTPAdapter
115
116
 
116
- pytest_plugins = ["docker_compose"]
117
-
118
117
  # Invoking this fixture: 'function_scoped_container_getter' starts all services
119
118
  @pytest.fixture(scope="function")
120
119
  def wait_for_api(function_scoped_container_getter):
@@ -160,7 +159,7 @@ pytest --use-running-containers
160
159
 
161
160
  With this flag, `pytest-docker-compose` checks that all containers are running
162
161
  during the project creation. If they are not running a warning is given and
163
- they are spun up anyways. They are then used for all the tests and NOT TORE
162
+ they are spun up anyways. They are then used for all the tests and NOT TORN
164
163
  DOWN afterwards.
165
164
 
166
165
  This mode is best used in combination with the `--docker-compose-no-build` flag since the newly build containers won't be used anyways. like so:
@@ -209,7 +208,7 @@ addopts = --docker-compose=/path/to/docker-compose.yml
209
208
 
210
209
  The option will be ignored for tests that do not use this plugin.
211
210
 
212
- See [Configuration Options](https://docs.pytest.org/en/latest/customize.html#adding-default-options) for more information on using configuration
211
+ See [Configuration Options](https://docs.pytest.org/en/stable/reference/customize.html#adding-default-options) for more information on using configuration
213
212
  files to modify pytest behavior.
214
213
 
215
214
  ### Remove volumes after tests
@@ -224,4 +223,3 @@ This option will be ignored if the plugin is not used. Again, this option can al
224
223
 
225
224
  For more examples on how to use this plugin look at the testing suite of this plugin itself! It will give you some examples for configuring `pyproject.toml` and how to use the different fixtures to run docker containers.
226
225
 
227
-
@@ -17,8 +17,8 @@ Make sure you have [Docker](https://docs.docker.com/get-docker/) installed.
17
17
 
18
18
  This plugin is automatically tested against the following software:
19
19
 
20
- - Python 3.9, 3.10, 3.11 and 3.12
21
- - pytest 7
20
+ - Python 3.10, 3.11, 3.12, 3.13 and 3.14
21
+ - pytest 7, 8 and 9
22
22
 
23
23
  **NOTE**: This plugin is **not** compatible with Python 2.
24
24
 
@@ -33,20 +33,17 @@ pip install pytest-docker-compose-v2
33
33
 
34
34
  ## Usage
35
35
 
36
- For performance reasons, the plugin is not enabled by default, so you must activate it manually in the tests that use it:
36
+ The plugin is automatically enabled when installed. To disable it for specific test runs, use:
37
37
 
38
- ```python
39
- pytest_plugins = ["docker_compose"]
38
+ ```shell
39
+ pytest -p no:docker_compose
40
40
  ```
41
41
 
42
-
43
- See [Installing and Using Plugins](https://docs.pytest.org/en/latest/plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file) for more information.
44
-
45
- To interact with Docker containers in your tests, use the following fixtures, these fixtures tell docker-compose to start all the services and then they can fetch the associated containers for use in a test:
42
+ To interact with Docker containers in your tests, use the following fixtures. These fixtures tell docker-compose to start all the services and then fetch the associated containers for use in a test:
46
43
 
47
44
  ### `function_scoped_container_getter`
48
45
 
49
- An object that fetches containers of the Docker `compose.container.Container` objects running during the test. The containers are fetched using `function_scoped_container_getter.get('service_name')` These containers each have an extra attribute called `network_info` added to them. This attribute has a list of `pytest_docker_compose.NetworkInfo` objects.
46
+ An object that fetches containers of the Docker `python_on_whales.Container` objects running during the test. The containers are fetched using `function_scoped_container_getter.get('service_name')` These containers each have an extra attribute called `network_info` added to them. This attribute has a list of `pytest_docker_compose.NetworkInfo` objects.
50
47
 
51
48
  This information can be used to configure API clients and other objects that will connect to services exposed by the Docker containers in your tests.
52
49
 
@@ -62,12 +59,12 @@ This information can be used to configure API clients and other objects that wil
62
59
 
63
60
  ### `docker_project`
64
61
 
65
- The `compose.project.Project` object that the containers are built from.
62
+ The `python_on_whales.DockerClient` object that the containers are built from.
66
63
  This fixture is generally only used internally by the plugin.
67
64
 
68
65
  ### Wider scoped fixtures
69
66
 
70
- To use the following fixtures please read [Use wider scoped fixtures](#use-wider-scope-fixtures)
67
+ To use the following fixtures please read [Use wider scoped fixtures](#use-wider-scoped-fixtures)
71
68
 
72
69
  - `class_scoped_container_getter`: Similar to `function_scoped_container_getter` just with a wider scope.
73
70
  - `module_scoped_container_getter`: Similar to `function_scoped_container_getter` just with a wider scope.
@@ -90,8 +87,6 @@ from urllib.parse import urljoin
90
87
  from urllib3.util.retry import Retry
91
88
  from requests.adapters import HTTPAdapter
92
89
 
93
- pytest_plugins = ["docker_compose"]
94
-
95
90
  # Invoking this fixture: 'function_scoped_container_getter' starts all services
96
91
  @pytest.fixture(scope="function")
97
92
  def wait_for_api(function_scoped_container_getter):
@@ -137,7 +132,7 @@ pytest --use-running-containers
137
132
 
138
133
  With this flag, `pytest-docker-compose` checks that all containers are running
139
134
  during the project creation. If they are not running a warning is given and
140
- they are spun up anyways. They are then used for all the tests and NOT TORE
135
+ they are spun up anyways. They are then used for all the tests and NOT TORN
141
136
  DOWN afterwards.
142
137
 
143
138
  This mode is best used in combination with the `--docker-compose-no-build` flag since the newly build containers won't be used anyways. like so:
@@ -186,7 +181,7 @@ addopts = --docker-compose=/path/to/docker-compose.yml
186
181
 
187
182
  The option will be ignored for tests that do not use this plugin.
188
183
 
189
- See [Configuration Options](https://docs.pytest.org/en/latest/customize.html#adding-default-options) for more information on using configuration
184
+ See [Configuration Options](https://docs.pytest.org/en/stable/reference/customize.html#adding-default-options) for more information on using configuration
190
185
  files to modify pytest behavior.
191
186
 
192
187
  ### Remove volumes after tests
@@ -0,0 +1,125 @@
1
+ [project]
2
+ name = "pytest-docker-compose-v2"
3
+ dynamic = ["version"]
4
+ description = "Manages Docker containers during your integration tests"
5
+ authors = [
6
+ {name = "Radu Suciu"},
7
+ {name = "Thomas Meckel"},
8
+ {name = "Roald Storm"},
9
+ {name = "Phoenix Zerin"},
10
+ ]
11
+ dependencies = [
12
+ "pytest>=7.2.2,<10",
13
+ "python-on-whales>=0.69.0,<1"
14
+ ]
15
+ requires-python = ">=3.10"
16
+ readme = "README.md"
17
+ license = {text = "Apache"}
18
+ keywords = [
19
+ "pytest",
20
+ "docker compose",
21
+ ]
22
+ classifiers = [
23
+ "Topic :: Software Development :: Testing",
24
+ "Intended Audience :: Developers",
25
+ "Development Status :: 4 - Beta",
26
+ "Framework :: Pytest",
27
+ "Programming Language :: Python",
28
+ "Programming Language :: Python :: 3 :: Only",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Programming Language :: Python :: 3.14",
34
+ "License :: OSI Approved :: Apache Software License",
35
+ "Operating System :: OS Independent",
36
+ ]
37
+
38
+ [project.entry-points.pytest11]
39
+ docker_compose = "pytest_docker_compose.plugin"
40
+
41
+ [project.urls]
42
+ repository="https://github.com/radusuciu/pytest-docker-compose-v2"
43
+
44
+ [build-system]
45
+ requires = ["hatchling"]
46
+ build-backend = "hatchling.build"
47
+
48
+ [dependency-groups]
49
+ dev = [
50
+ "ruff>=0.14.9",
51
+ "bumpver>=2022.1120",
52
+ "git-cliff>=2.0.4",
53
+ "psycopg2-binary>=2.9.9",
54
+ "fastapi>=0.110.0",
55
+ "uvicorn>=0.27.1",
56
+ "mypy>=1.19.1",
57
+ "requests>=2.32.5",
58
+ "tox>=4.30.3",
59
+ "tox-uv>=1.28.1",
60
+ "pytest>=8,<10",
61
+ ]
62
+
63
+ [tool.hatch.version]
64
+ path = "pytest_docker_compose/__init__.py"
65
+
66
+ [tool.hatch.build.targets.wheel]
67
+ packages = ["pytest_docker_compose"]
68
+
69
+ [tool.pytest.ini_options]
70
+ addopts = "-m 'not (should_fail or multiple_compose_files)' '--docker-compose' './tests/pytest_docker_compose_tests/my_network' '--docker-compose-no-build'"
71
+ markers = [
72
+ "should_fail: marks a set of test that should throw an error when run",
73
+ "multiple_compose_files: marks a test that uses more than one compose file",
74
+ ]
75
+ minversion = "7.2"
76
+
77
+ [tool.ruff]
78
+ line-length = 88
79
+ target-version = "py311"
80
+
81
+ [tool.ruff.lint.mccabe]
82
+ # Unlike Flake8, default to a complexity level of 10.
83
+ max-complexity = 10
84
+
85
+ [tool.bumpver]
86
+ current_version = "0.2.0"
87
+ version_pattern = "MAJOR.MINOR.PATCH[GITHASH]"
88
+ commit_message = "bump version {old_version} -> {new_version}"
89
+ commit = true
90
+ tag = true
91
+ push = false
92
+
93
+ [tool.bumpver.file_patterns]
94
+ "pyproject.toml" = [
95
+ 'current_version = "{version}"',
96
+ ]
97
+ "pytest_docker_compose/__init__.py" = [
98
+ '__version__ = "{version}"',
99
+ ]
100
+
101
+ [tool.tox]
102
+ legacy_tox_ini = """
103
+ [tox]
104
+ envlist = py{310,311,312,313,314}-pytest{7,8,9}
105
+
106
+ [testenv]
107
+ deps =
108
+ pytest7: pytest>=7,<8
109
+ pytest8: pytest>=8,<9
110
+ pytest9: pytest>=9,<10
111
+ python_on_whales
112
+ ruff
113
+ mypy
114
+ requests
115
+ allowlist_externals=
116
+ docker
117
+ commands=
118
+ ruff check pytest_docker_compose
119
+ mypy --namespace-packages --ignore-missing-imports pytest_docker_compose
120
+ pytest
121
+ pytest -m multiple_compose_files --docker-compose ./tests/pytest_docker_compose_tests/my_network,./tests/pytest_docker_compose_tests/my_network/extra-service.yml
122
+ docker compose -f tests/pytest_docker_compose_tests/my_network/docker-compose.yml up -d
123
+ pytest --use-running-containers
124
+ docker compose -f tests/pytest_docker_compose_tests/my_network/docker-compose.yml down -v
125
+ """