pytest-databases 0.13.0__tar.gz → 0.14.1__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 (89) hide show
  1. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.github/workflows/cd.yaml +1 -1
  2. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.github/workflows/ci.yaml +4 -4
  3. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.github/workflows/docs.yml +2 -2
  4. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.github/workflows/pr-title.yaml +1 -1
  5. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.github/workflows/release.yaml +1 -1
  6. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/PKG-INFO +2 -2
  7. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/README.md +1 -1
  8. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/postgres.rst +14 -0
  9. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/pyproject.toml +2 -3
  10. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/_service.py +2 -1
  11. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/postgres.py +28 -0
  12. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/redis.py +0 -6
  13. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_redis.py +21 -10
  14. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/uv.lock +2 -27
  15. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.github/CODEOWNERS +0 -0
  16. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.github/dependabot.yaml +0 -0
  17. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.gitignore +0 -0
  18. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.pre-commit-config.yaml +0 -0
  19. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.sourcery.yaml +0 -0
  20. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.vscode/launch.json +0 -0
  21. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/.vscode/settings.json +0 -0
  22. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/CODEOWNERS +0 -0
  23. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/CONTRIBUTING.rst +0 -0
  24. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/LICENSE +0 -0
  25. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/Makefile +0 -0
  26. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/.gitignore +0 -0
  27. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/__init__.py +0 -0
  28. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/_static/.gitkeep +0 -0
  29. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/_static/custom.css +0 -0
  30. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/_static/logo.svg +0 -0
  31. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/changelog.rst +0 -0
  32. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/conf.py +0 -0
  33. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/contribution-guide.rst +0 -0
  34. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/getting-started/basic-usage.rst +0 -0
  35. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/getting-started/configuration.rst +0 -0
  36. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/getting-started/enabling-plugins.rst +0 -0
  37. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/getting-started/index.rst +0 -0
  38. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/getting-started/installation.rst +0 -0
  39. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/getting-started/next-steps.rst +0 -0
  40. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/index.rst +0 -0
  41. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/azure_blob_storage.rst +0 -0
  42. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/bigquery.rst +0 -0
  43. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/cockroachdb.rst +0 -0
  44. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/elasticsearch.rst +0 -0
  45. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/index.rst +0 -0
  46. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/mariadb.rst +0 -0
  47. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/minio.rst +0 -0
  48. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/mysql.rst +0 -0
  49. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/oracle.rst +0 -0
  50. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/redis.rst +0 -0
  51. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/spanner.rst +0 -0
  52. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/sqlserver.rst +0 -0
  53. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/docs/supported-databases/valkey.rst +0 -0
  54. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/scripts/__init__.py +0 -0
  55. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/scripts/build_docs.py +0 -0
  56. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/scripts/convert_docs.sh +0 -0
  57. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/scripts/install-hatch.sh +0 -0
  58. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/sonar-project.properties +0 -0
  59. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/__init__.py +0 -0
  60. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/__metadata__.py +0 -0
  61. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/__init__.py +0 -0
  62. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/azure_blob.py +0 -0
  63. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/bigquery.py +0 -0
  64. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/cockroachdb.py +0 -0
  65. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/elastic_search.py +0 -0
  66. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/mariadb.py +0 -0
  67. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/minio.py +0 -0
  68. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/mssql.py +0 -0
  69. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/mysql.py +0 -0
  70. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/oracle.py +0 -0
  71. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/spanner.py +0 -0
  72. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/docker/valkey.py +0 -0
  73. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/helpers.py +0 -0
  74. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/py.typed +0 -0
  75. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/src/pytest_databases/types.py +0 -0
  76. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/__init__.py +0 -0
  77. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/conftest.py +0 -0
  78. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_azure_blob.py +0 -0
  79. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_bigquery.py +0 -0
  80. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_cockroachdb.py +0 -0
  81. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_elasticsearch.py +0 -0
  82. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_mariadb.py +0 -0
  83. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_minio.py +0 -0
  84. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_mssql.py +0 -0
  85. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_mysql.py +0 -0
  86. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_oracle.py +0 -0
  87. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_postgres.py +0 -0
  88. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_spanner.py +0 -0
  89. {pytest_databases-0.13.0 → pytest_databases-0.14.1}/tests/test_valkey.py +0 -0
@@ -13,7 +13,7 @@ jobs:
13
13
  release_body: ${{ steps.git-cliff.outputs.content }}
14
14
  steps:
15
15
  - name: Checkout
16
- uses: actions/checkout@v4
16
+ uses: actions/checkout@v5
17
17
  with:
18
18
  fetch-depth: 0
19
19
 
@@ -26,7 +26,7 @@ jobs:
26
26
  cdist-group: [1, 2, 3]
27
27
 
28
28
  steps:
29
- - uses: actions/checkout@v4
29
+ - uses: actions/checkout@v5
30
30
 
31
31
  - name: Install additional dependencies
32
32
  run: sudo apt-get update && sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 libmariadb-dev && sudo apt-get autoremove -y && sudo apt-get clean -y
@@ -58,7 +58,7 @@ jobs:
58
58
 
59
59
  - if: matrix.python-version == '3.12'
60
60
  name: Upload coverage reports to Codecov
61
- uses: codecov/codecov-action@v5.4.3
61
+ uses: codecov/codecov-action@v5.5.0
62
62
  with:
63
63
  token: ${{ secrets.CODECOV_TOKEN }}
64
64
  slug: litestar-org/pytest-databases
@@ -70,7 +70,7 @@ jobs:
70
70
  - name: Install additional dependencies
71
71
  run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 libmariadb-dev
72
72
 
73
- - uses: actions/checkout@v4
73
+ - uses: actions/checkout@v5
74
74
 
75
75
  - name: Set up Python
76
76
  uses: actions/setup-python@v5
@@ -94,7 +94,7 @@ jobs:
94
94
  # runs-on: ubuntu-latest
95
95
  # steps:
96
96
  # - name: Check out repository
97
- # uses: actions/checkout@v4
97
+ # uses: actions/checkout@v5
98
98
  # with:
99
99
  # fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
100
100
  # - name: Download Artifacts
@@ -20,7 +20,7 @@ jobs:
20
20
  url: ${{ steps.deployment.outputs.page_url }}
21
21
  runs-on: ubuntu-latest
22
22
  steps:
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v5
24
24
 
25
25
  - name: Install additional dependencies
26
26
  run: sudo apt-get update && sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 libmariadb-dev && sudo apt-get autoremove -y && sudo apt-get clean -y
@@ -43,7 +43,7 @@ jobs:
43
43
  run: uv run scripts/build_docs.py dist/docs
44
44
 
45
45
  - name: Upload artifact
46
- uses: actions/upload-pages-artifact@v3
46
+ uses: actions/upload-pages-artifact@v4
47
47
  with:
48
48
  path: dist/docs/
49
49
 
@@ -15,6 +15,6 @@ jobs:
15
15
  name: Validate PR title
16
16
  runs-on: ubuntu-latest
17
17
  steps:
18
- - uses: amannn/action-semantic-pull-request@v5
18
+ - uses: amannn/action-semantic-pull-request@v6
19
19
  env:
20
20
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -16,7 +16,7 @@ jobs:
16
16
  run: sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 libmariadb-dev
17
17
 
18
18
  - name: Check out repository
19
- uses: actions/checkout@v4
19
+ uses: actions/checkout@v5
20
20
 
21
21
  - name: Install uv
22
22
  uses: astral-sh/setup-uv@v6
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-databases
3
- Version: 0.13.0
3
+ Version: 0.14.1
4
4
  Summary: Reusable database fixtures for any and all databases.
5
5
  Project-URL: Documentation, https://github.com/litestar-org/pytest-databases#readme
6
6
  Project-URL: Issues, https://github.com/litestar-org/pytest-databases/issues
@@ -133,7 +133,7 @@ def test_one(postgres_service: PostgresService) -> None:
133
133
 
134
134
  ## Documentation
135
135
 
136
- Full documentation is available at [https://pytest-databases.readthedocs.io/](https://pytest-databases.readthedocs.io/)
136
+ Full documentation is available at [https://litestar-org.github.io/pytest-databases/latest/](https://litestar-org.github.io/pytest-databases/latest/)
137
137
 
138
138
  ## Contributing
139
139
 
@@ -75,7 +75,7 @@ def test_one(postgres_service: PostgresService) -> None:
75
75
 
76
76
  ## Documentation
77
77
 
78
- Full documentation is available at [https://pytest-databases.readthedocs.io/](https://pytest-databases.readthedocs.io/)
78
+ Full documentation is available at [https://litestar-org.github.io/pytest-databases/latest/](https://litestar-org.github.io/pytest-databases/latest/)
79
79
 
80
80
  ## Contributing
81
81
 
@@ -36,6 +36,7 @@ Usage Example
36
36
  Available Fixtures
37
37
  ------------------
38
38
 
39
+ * ``postgres_host``: The PostgreSQL host address (defaults to "127.0.0.1", can be overridden with ``POSTGRES_HOST`` environment variable).
39
40
  * ``postgres_user``: The PostgreSQL user.
40
41
  * ``postgres_password``: The PostgreSQL password.
41
42
  * ``postgres_database``: The PostgreSQL database name to use.
@@ -55,6 +56,19 @@ The following version-specific fixtures are also available:
55
56
  * ``postgres_17_image``, ``postgres_17_service``, ``postgres_17_connection``: PostgreSQL 17.x
56
57
  * ``pgvector_image``, ``pgvector_service``. ``pgvector_connection``: Latest Available pgvector Docker image.
57
58
 
59
+ Configuration
60
+ -------------
61
+
62
+ PostgreSQL services can be configured using environment variables:
63
+
64
+ * ``POSTGRES_HOST``: The host address for the PostgreSQL container (default: "127.0.0.1")
65
+
66
+ Example usage with custom host:
67
+
68
+ .. code-block:: bash
69
+
70
+ export POSTGRES_HOST="192.168.1.100"
71
+ pytest
58
72
 
59
73
  Service API
60
74
  -----------
@@ -12,7 +12,7 @@ license = "MIT"
12
12
  name = "pytest-databases"
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.9"
15
- version = "0.13.0"
15
+ version = "0.14.1"
16
16
  #
17
17
  authors = [{ name = "Cody Fincher", email = "cody@litestar.dev" }]
18
18
  keywords = [
@@ -84,7 +84,6 @@ dev = [
84
84
  "pytest-mock",
85
85
  "pytest-click",
86
86
  "pytest-xdist",
87
- "pytest-sugar",
88
87
  "slotscheck",
89
88
  "psycopg-binary", # This fixes tests failing on M series CPUs.
90
89
  # lint
@@ -125,7 +124,7 @@ dev = [
125
124
  allow_dirty = true
126
125
  commit = true
127
126
  commit_args = "--no-verify"
128
- current_version = "0.13.0"
127
+ current_version = "0.14.0"
129
128
  ignore_missing_files = false
130
129
  ignore_missing_version = false
131
130
  message = "chore(release): bump to v{new_version}"
@@ -126,6 +126,7 @@ class DockerService(AbstractContextManager):
126
126
  image: str,
127
127
  container_port: int,
128
128
  name: str,
129
+ container_host: str = "127.0.0.1",
129
130
  command: str | None = None,
130
131
  env: dict[str, Any] | None = None,
131
132
  exec_after_start: str | list[str] | None = None,
@@ -187,7 +188,7 @@ class DockerService(AbstractContextManager):
187
188
  container.ports[next(k for k in container.ports if k.startswith(str(container_port)))][0]["HostPort"]
188
189
  )
189
190
  service = ServiceContainer(
190
- host="127.0.0.1",
191
+ host=container_host,
191
192
  port=host_port,
192
193
  )
193
194
 
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import dataclasses
4
+ import os
4
5
  from contextlib import contextmanager
5
6
  from typing import TYPE_CHECKING
6
7
 
@@ -32,6 +33,11 @@ class PostgresService(ServiceContainer):
32
33
  user: str
33
34
 
34
35
 
36
+ @pytest.fixture(autouse=False, scope="session")
37
+ def postgres_host() -> str:
38
+ return os.environ.get("POSTGRES_HOST", "127.0.0.1")
39
+
40
+
35
41
  @pytest.fixture(autouse=False, scope="session")
36
42
  def postgres_password() -> str:
37
43
  return "super-secret"
@@ -47,6 +53,7 @@ def _provide_postgres_service(
47
53
  docker_service: DockerService,
48
54
  image: str,
49
55
  name: str,
56
+ host: str,
50
57
  user: str,
51
58
  password: str,
52
59
  xdist_postgres_isolate: XdistIsolationLevel,
@@ -79,6 +86,7 @@ def _provide_postgres_service(
79
86
  with docker_service.run(
80
87
  image=image,
81
88
  check=check,
89
+ container_host=host,
82
90
  container_port=5432,
83
91
  name=name,
84
92
  env={
@@ -100,6 +108,7 @@ def _provide_postgres_service(
100
108
  def postgres_11_service(
101
109
  docker_service: DockerService,
102
110
  xdist_postgres_isolation_level: XdistIsolationLevel,
111
+ postgres_host: str,
103
112
  postgres_user: str,
104
113
  postgres_password: str,
105
114
  ) -> Generator[PostgresService, None, None]:
@@ -108,6 +117,7 @@ def postgres_11_service(
108
117
  image="postgres:11",
109
118
  name="postgres-11",
110
119
  xdist_postgres_isolate=xdist_postgres_isolation_level,
120
+ host=postgres_host,
111
121
  user=postgres_user,
112
122
  password=postgres_password,
113
123
  ) as service:
@@ -118,6 +128,7 @@ def postgres_11_service(
118
128
  def postgres_12_service(
119
129
  docker_service: DockerService,
120
130
  xdist_postgres_isolation_level: XdistIsolationLevel,
131
+ postgres_host: str,
121
132
  postgres_user: str,
122
133
  postgres_password: str,
123
134
  ) -> Generator[PostgresService, None, None]:
@@ -126,6 +137,7 @@ def postgres_12_service(
126
137
  image="postgres:12",
127
138
  name="postgres-12",
128
139
  xdist_postgres_isolate=xdist_postgres_isolation_level,
140
+ host=postgres_host,
129
141
  user=postgres_user,
130
142
  password=postgres_password,
131
143
  ) as service:
@@ -136,6 +148,7 @@ def postgres_12_service(
136
148
  def postgres_13_service(
137
149
  docker_service: DockerService,
138
150
  xdist_postgres_isolation_level: XdistIsolationLevel,
151
+ postgres_host: str,
139
152
  postgres_user: str,
140
153
  postgres_password: str,
141
154
  ) -> Generator[PostgresService, None, None]:
@@ -144,6 +157,7 @@ def postgres_13_service(
144
157
  image="postgres:13",
145
158
  name="postgres-13",
146
159
  xdist_postgres_isolate=xdist_postgres_isolation_level,
160
+ host=postgres_host,
147
161
  user=postgres_user,
148
162
  password=postgres_password,
149
163
  ) as service:
@@ -154,6 +168,7 @@ def postgres_13_service(
154
168
  def postgres_14_service(
155
169
  docker_service: DockerService,
156
170
  xdist_postgres_isolation_level: XdistIsolationLevel,
171
+ postgres_host: str,
157
172
  postgres_user: str,
158
173
  postgres_password: str,
159
174
  ) -> Generator[PostgresService, None, None]:
@@ -162,6 +177,7 @@ def postgres_14_service(
162
177
  image="postgres:14",
163
178
  name="postgres-14",
164
179
  xdist_postgres_isolate=xdist_postgres_isolation_level,
180
+ host=postgres_host,
165
181
  user=postgres_user,
166
182
  password=postgres_password,
167
183
  ) as service:
@@ -172,6 +188,7 @@ def postgres_14_service(
172
188
  def postgres_15_service(
173
189
  docker_service: DockerService,
174
190
  xdist_postgres_isolation_level: XdistIsolationLevel,
191
+ postgres_host: str,
175
192
  postgres_user: str,
176
193
  postgres_password: str,
177
194
  ) -> Generator[PostgresService, None, None]:
@@ -180,6 +197,7 @@ def postgres_15_service(
180
197
  image="postgres:15",
181
198
  name="postgres-15",
182
199
  xdist_postgres_isolate=xdist_postgres_isolation_level,
200
+ host=postgres_host,
183
201
  user=postgres_user,
184
202
  password=postgres_password,
185
203
  ) as service:
@@ -190,6 +208,7 @@ def postgres_15_service(
190
208
  def postgres_16_service(
191
209
  docker_service: DockerService,
192
210
  xdist_postgres_isolation_level: XdistIsolationLevel,
211
+ postgres_host: str,
193
212
  postgres_user: str,
194
213
  postgres_password: str,
195
214
  ) -> Generator[PostgresService, None, None]:
@@ -198,6 +217,7 @@ def postgres_16_service(
198
217
  image="postgres:16",
199
218
  name="postgres-16",
200
219
  xdist_postgres_isolate=xdist_postgres_isolation_level,
220
+ host=postgres_host,
201
221
  user=postgres_user,
202
222
  password=postgres_password,
203
223
  ) as service:
@@ -208,6 +228,7 @@ def postgres_16_service(
208
228
  def postgres_17_service(
209
229
  docker_service: DockerService,
210
230
  xdist_postgres_isolation_level: XdistIsolationLevel,
231
+ postgres_host: str,
211
232
  postgres_user: str,
212
233
  postgres_password: str,
213
234
  ) -> Generator[PostgresService, None, None]:
@@ -216,6 +237,7 @@ def postgres_17_service(
216
237
  image="postgres:17",
217
238
  name="postgres-17",
218
239
  xdist_postgres_isolate=xdist_postgres_isolation_level,
240
+ host=postgres_host,
219
241
  user=postgres_user,
220
242
  password=postgres_password,
221
243
  ) as service:
@@ -344,6 +366,7 @@ def postgres_service(
344
366
  docker_service: DockerService,
345
367
  postgres_image: str,
346
368
  xdist_postgres_isolation_level: XdistIsolationLevel,
369
+ postgres_host: str,
347
370
  postgres_user: str,
348
371
  postgres_password: str,
349
372
  ) -> Generator[PostgresService, None, None]:
@@ -352,6 +375,7 @@ def postgres_service(
352
375
  image=postgres_image,
353
376
  name="postgres",
354
377
  xdist_postgres_isolate=xdist_postgres_isolation_level,
378
+ host=postgres_host,
355
379
  user=postgres_user,
356
380
  password=postgres_password,
357
381
  ) as service:
@@ -384,6 +408,7 @@ def pgvector_service(
384
408
  docker_service: DockerService,
385
409
  pgvector_image: str,
386
410
  xdist_postgres_isolation_level: XdistIsolationLevel,
411
+ postgres_host: str,
387
412
  postgres_user: str,
388
413
  postgres_password: str,
389
414
  ) -> Generator[PostgresService, None, None]:
@@ -392,6 +417,7 @@ def pgvector_service(
392
417
  image=pgvector_image,
393
418
  name="pgvector",
394
419
  xdist_postgres_isolate=xdist_postgres_isolation_level,
420
+ host=postgres_host,
395
421
  user=postgres_user,
396
422
  password=postgres_password,
397
423
  ) as service:
@@ -424,6 +450,7 @@ def alloydb_omni_service(
424
450
  docker_service: DockerService,
425
451
  pgvector_image: str,
426
452
  xdist_postgres_isolation_level: XdistIsolationLevel,
453
+ postgres_host: str,
427
454
  postgres_user: str,
428
455
  postgres_password: str,
429
456
  ) -> Generator[PostgresService, None, None]:
@@ -432,6 +459,7 @@ def alloydb_omni_service(
432
459
  image=pgvector_image,
433
460
  name="alloydb-omni",
434
461
  xdist_postgres_isolate=xdist_postgres_isolation_level,
462
+ host=postgres_host,
435
463
  user=postgres_user,
436
464
  password=postgres_password,
437
465
  ) as service:
@@ -62,8 +62,6 @@ def redis_service(
62
62
  db = 0
63
63
  if worker_num is not None:
64
64
  if xdist_redis_isolation_level == "database":
65
- container_num = worker_num // 1
66
- name += f"_{container_num + 1}"
67
65
  db = worker_num
68
66
  else:
69
67
  name += f"_{worker_num + 1}"
@@ -94,8 +92,6 @@ def dragonfly_service(
94
92
  db = 0
95
93
  if worker_num is not None:
96
94
  if xdist_redis_isolation_level == "database":
97
- container_num = worker_num // 1
98
- name += f"_{container_num + 1}"
99
95
  db = worker_num
100
96
  else:
101
97
  name += f"_{worker_num + 1}"
@@ -136,8 +132,6 @@ def keydb_service(
136
132
  db = 0
137
133
  if worker_num is not None:
138
134
  if xdist_redis_isolation_level == "database":
139
- container_num = worker_num // 1
140
- name += f"_{container_num + 1}"
141
135
  db = worker_num
142
136
  else:
143
137
  name += f"_{worker_num + 1}"
@@ -46,7 +46,7 @@ def redis_image():
46
46
  return "{redis_image_name}"
47
47
 
48
48
  def test_redis_service(redis_service: RedisService) -> None:
49
- assert redis.Redis.from_url("redis://", host=redis_service.host, port=redis_service.port).ping()
49
+ assert redis.Redis(host=redis_service.host, port=redis_service.port).ping()
50
50
  """)
51
51
  result = pytester.runpytest()
52
52
  result.assert_outcomes(passed=1)
@@ -64,7 +64,7 @@ pytest_plugins = [
64
64
  ]
65
65
 
66
66
  def test_redis_service({redis_compatible_service}: RedisService) -> None:
67
- assert redis.Redis.from_url("redis://", host={redis_compatible_service}.host, port={redis_compatible_service}.port).ping()
67
+ assert redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port).ping()
68
68
  """)
69
69
  result = pytester.runpytest()
70
70
  result.assert_outcomes(passed=1)
@@ -82,20 +82,31 @@ pytest_plugins = [
82
82
  ]
83
83
 
84
84
  def test_one({redis_compatible_service}: RedisService) -> None:
85
- client = redis.Redis.from_url("redis://", host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
86
- assert not client.get("one")
87
- client.set("one", "1")
85
+ client = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
88
86
  assert {redis_compatible_service}.db == get_xdist_worker_num()
87
+ assert not client.get("one")
88
+ client.set("one", "0")
89
+ assert client.get("one") == b"0"
89
90
 
90
91
 
91
92
  def test_two({redis_compatible_service}: RedisService) -> None:
92
- client = redis.Redis.from_url("redis://", host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
93
+ client = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
94
+ assert {redis_compatible_service}.db == get_xdist_worker_num()
93
95
  assert not client.get("one")
94
96
  client.set("one", "1")
95
- assert {redis_compatible_service}.db == get_xdist_worker_num()
97
+ assert client.get("one") == b"1"
98
+
99
+
100
+ def test_use_same_db({redis_compatible_service}: RedisService) -> None:
101
+ client_0 = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db=0)
102
+ client_1 = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db=1)
103
+ client_0.set("foo", "0")
104
+ client_1.set("foo", "1")
105
+ assert client_0.get("foo") == b"0"
106
+ assert client_1.get("foo") == b"1"
96
107
  """)
97
108
  result = pytester.runpytest("-n", "2")
98
- result.assert_outcomes(passed=2)
109
+ result.assert_outcomes(passed=3)
99
110
 
100
111
 
101
112
  def test_xdist_isolate_server(pytester: pytest.Pytester, redis_compatible_service: str) -> None:
@@ -115,14 +126,14 @@ def xdist_redis_isolation_level():
115
126
 
116
127
 
117
128
  def test_one({redis_compatible_service}: RedisService) -> None:
118
- client = redis.Redis.from_url("redis://", host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
129
+ client = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
119
130
  assert not client.get("one")
120
131
  client.set("one", "1")
121
132
  assert {redis_compatible_service}.db == 0
122
133
 
123
134
 
124
135
  def test_two({redis_compatible_service}: RedisService) -> None:
125
- client = redis.Redis.from_url("redis://", host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
136
+ client = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db={redis_compatible_service}.db)
126
137
  assert not client.get("one")
127
138
  client.set("one", "1")
128
139
  assert {redis_compatible_service}.db == 0
@@ -1,5 +1,5 @@
1
1
  version = 1
2
- revision = 2
2
+ revision = 3
3
3
  requires-python = ">=3.9"
4
4
  resolution-markers = [
5
5
  "python_full_version >= '3.13'",
@@ -2010,7 +2010,7 @@ wheels = [
2010
2010
 
2011
2011
  [[package]]
2012
2012
  name = "pytest-databases"
2013
- version = "0.13.0"
2013
+ version = "0.14.1"
2014
2014
  source = { editable = "." }
2015
2015
  dependencies = [
2016
2016
  { name = "docker" },
@@ -2085,7 +2085,6 @@ dev = [
2085
2085
  { name = "pytest-cov" },
2086
2086
  { name = "pytest-databases", extra = ["azure-storage", "bigquery", "cockroachdb", "dragonfly", "elasticsearch7", "elasticsearch8", "keydb", "mariadb", "minio", "mssql", "mysql", "oracle", "postgres", "redis", "spanner", "valkey"] },
2087
2087
  { name = "pytest-mock" },
2088
- { name = "pytest-sugar" },
2089
2088
  { name = "pytest-xdist" },
2090
2089
  { name = "ruff" },
2091
2090
  { name = "shibuya" },
@@ -2154,7 +2153,6 @@ dev = [
2154
2153
  { name = "pytest-cov" },
2155
2154
  { name = "pytest-databases", extras = ["azure-storage", "bigquery", "cockroachdb", "dragonfly", "elasticsearch7", "elasticsearch8", "keydb", "mssql", "mysql", "mariadb", "oracle", "postgres", "redis", "spanner", "minio", "valkey"] },
2156
2155
  { name = "pytest-mock" },
2157
- { name = "pytest-sugar" },
2158
2156
  { name = "pytest-xdist" },
2159
2157
  { name = "ruff" },
2160
2158
  { name = "shibuya" },
@@ -2192,20 +2190,6 @@ wheels = [
2192
2190
  { url = "https://files.pythonhosted.org/packages/f2/3b/b26f90f74e2986a82df6e7ac7e319b8ea7ccece1caec9f8ab6104dc70603/pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f", size = 9863, upload-time = "2024-03-21T22:14:02.694Z" },
2193
2191
  ]
2194
2192
 
2195
- [[package]]
2196
- name = "pytest-sugar"
2197
- version = "1.0.0"
2198
- source = { registry = "https://pypi.org/simple" }
2199
- dependencies = [
2200
- { name = "packaging" },
2201
- { name = "pytest" },
2202
- { name = "termcolor" },
2203
- ]
2204
- sdist = { url = "https://files.pythonhosted.org/packages/f5/ac/5754f5edd6d508bc6493bc37d74b928f102a5fff82d9a80347e180998f08/pytest-sugar-1.0.0.tar.gz", hash = "sha256:6422e83258f5b0c04ce7c632176c7732cab5fdb909cb39cca5c9139f81276c0a", size = 14992, upload-time = "2024-02-01T18:30:36.735Z" }
2205
- wheels = [
2206
- { url = "https://files.pythonhosted.org/packages/92/fb/889f1b69da2f13691de09a111c16c4766a433382d44aa0ecf221deded44a/pytest_sugar-1.0.0-py3-none-any.whl", hash = "sha256:70ebcd8fc5795dc457ff8b69d266a4e2e8a74ae0c3edc749381c64b5246c8dfd", size = 10171, upload-time = "2024-02-01T18:30:29.395Z" },
2207
- ]
2208
-
2209
2193
  [[package]]
2210
2194
  name = "pytest-xdist"
2211
2195
  version = "3.6.1"
@@ -3042,15 +3026,6 @@ wheels = [
3042
3026
  { url = "https://files.pythonhosted.org/packages/40/44/4a5f08c96eb108af5cb50b41f76142f0afa346dfa99d5296fe7202a11854/tabulate-0.9.0-py3-none-any.whl", hash = "sha256:024ca478df22e9340661486f85298cff5f6dcdba14f3813e8830015b9ed1948f", size = 35252, upload-time = "2022-10-06T17:21:44.262Z" },
3043
3027
  ]
3044
3028
 
3045
- [[package]]
3046
- name = "termcolor"
3047
- version = "3.1.0"
3048
- source = { registry = "https://pypi.org/simple" }
3049
- sdist = { url = "https://files.pythonhosted.org/packages/ca/6c/3d75c196ac07ac8749600b60b03f4f6094d54e132c4d94ebac6ee0e0add0/termcolor-3.1.0.tar.gz", hash = "sha256:6a6dd7fbee581909eeec6a756cff1d7f7c376063b14e4a298dc4980309e55970", size = 14324, upload-time = "2025-04-30T11:37:53.791Z" }
3050
- wheels = [
3051
- { url = "https://files.pythonhosted.org/packages/4f/bd/de8d508070629b6d84a30d01d57e4a65c69aa7f5abe7560b8fad3b50ea59/termcolor-3.1.0-py3-none-any.whl", hash = "sha256:591dd26b5c2ce03b9e43f391264626557873ce1d379019786f99b0c2bee140aa", size = 7684, upload-time = "2025-04-30T11:37:52.382Z" },
3052
- ]
3053
-
3054
3029
  [[package]]
3055
3030
  name = "tomli"
3056
3031
  version = "2.2.1"