pytest-databases 0.8.0__tar.gz → 0.10.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 (72) hide show
  1. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/PKG-INFO +8 -10
  2. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/README.md +1 -1
  3. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/pyproject.toml +14 -23
  4. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/__init__.py +25 -14
  5. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/alloydb_omni.py +14 -20
  6. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/azure_blob.py +5 -8
  7. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/bigquery.py +8 -11
  8. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/cockroachdb.py +14 -20
  9. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.postgres.yml +8 -0
  10. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/dragonfly.py +7 -21
  11. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/elastic_search.py +19 -22
  12. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/keydb.py +7 -21
  13. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/mariadb.py +22 -47
  14. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/mssql.py +53 -33
  15. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/mysql.py +42 -45
  16. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/oracle.py +20 -23
  17. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/postgres.py +156 -119
  18. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/redis.py +10 -13
  19. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/spanner.py +7 -10
  20. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/valkey.py +7 -21
  21. pytest_databases-0.10.0/src/pytest_databases/helpers.py +21 -0
  22. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/conftest.py +0 -5
  23. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_alloydb_omni.py +11 -9
  24. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_azure_blob.py +1 -5
  25. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_bigquery.py +3 -5
  26. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_cockroachdb.py +7 -10
  27. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_dragonfly.py +3 -6
  28. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_elasticsearch.py +17 -18
  29. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_keydb.py +3 -6
  30. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_mariadb.py +18 -20
  31. pytest_databases-0.10.0/tests/docker/test_mssql.py +98 -0
  32. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_mysql.py +30 -51
  33. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_oracle.py +20 -22
  34. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_postgres.py +71 -49
  35. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_redis.py +2 -5
  36. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_spanner.py +3 -5
  37. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/test_valkey.py +4 -6
  38. pytest_databases-0.8.0/src/pytest_databases/helpers.py +0 -79
  39. pytest_databases-0.8.0/tests/docker/test_mssql.py +0 -93
  40. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/.gitignore +0 -0
  41. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/.pre-commit-config.yaml +0 -0
  42. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/.sourcery.yaml +0 -0
  43. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/.vscode/launch.json +0 -0
  44. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/.vscode/settings.json +0 -0
  45. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/CODEOWNERS +0 -0
  46. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/CONTRIBUTING.rst +0 -0
  47. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/LICENSE +0 -0
  48. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/Makefile +0 -0
  49. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/scripts/__init__.py +0 -0
  50. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/scripts/build_docs.py +0 -0
  51. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/scripts/convert_docs.sh +0 -0
  52. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/scripts/install-hatch.sh +0 -0
  53. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/sonar-project.properties +0 -0
  54. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/__init__.py +0 -0
  55. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/__metadata__.py +0 -0
  56. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.alloydb-omni.yml +0 -0
  57. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.azurite.yml +0 -0
  58. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.bigquery.yml +0 -0
  59. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.cockroachdb.yml +0 -0
  60. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.dragonfly.yml +0 -0
  61. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.elasticsearch.yml +0 -0
  62. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.keydb.yml +0 -0
  63. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.mariadb.yml +0 -0
  64. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.mssql.yml +0 -0
  65. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.mysql.yml +0 -0
  66. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.oracle.yml +0 -0
  67. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.redis.yml +0 -0
  68. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.spanner.yml +0 -0
  69. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.valkey.yml +0 -0
  70. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/src/pytest_databases/py.typed +0 -0
  71. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/__init__.py +0 -0
  72. {pytest_databases-0.8.0 → pytest_databases-0.10.0}/tests/docker/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pytest-databases
3
- Version: 0.8.0
3
+ Version: 0.10.0
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
@@ -8,7 +8,7 @@ Project-URL: Source, https://github.com/litestar-org/pytest-databases
8
8
  Author-email: Cody Fincher <cody.fincher@gmail.com>
9
9
  License-Expression: MIT
10
10
  License-File: LICENSE
11
- Keywords: alloydb,alloydbomni,bigquery,cockroachdb,database,duckdb,elasticsearch,migration,mssql,mysql,oracle,postgres,redis,spanner
11
+ Keywords: alloydb,alloydbomni,azure,bigquery,cockroachdb,database,duckdb,elasticsearch,migration,mssql,mysql,oracle,postgres,redis,spanner
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3.8
@@ -29,25 +29,23 @@ Requires-Dist: psycopg; extra == 'cockroachdb'
29
29
  Provides-Extra: dragonfly
30
30
  Requires-Dist: redis; extra == 'dragonfly'
31
31
  Provides-Extra: elasticsearch7
32
- Requires-Dist: elasticsearch7[async]; extra == 'elasticsearch7'
32
+ Requires-Dist: elasticsearch7; extra == 'elasticsearch7'
33
33
  Provides-Extra: elasticsearch8
34
- Requires-Dist: elasticsearch8[async]; extra == 'elasticsearch8'
34
+ Requires-Dist: elasticsearch8; extra == 'elasticsearch8'
35
35
  Provides-Extra: keydb
36
36
  Requires-Dist: redis; extra == 'keydb'
37
37
  Provides-Extra: mssql
38
- Requires-Dist: aioodbc; extra == 'mssql'
38
+ Requires-Dist: pymssql; extra == 'mssql'
39
39
  Provides-Extra: mysql
40
- Requires-Dist: asyncmy>=0.2.9; extra == 'mysql'
40
+ Requires-Dist: pymysql; extra == 'mysql'
41
41
  Provides-Extra: oracle
42
42
  Requires-Dist: oracledb; extra == 'oracle'
43
43
  Provides-Extra: postgres
44
- Requires-Dist: asyncpg>=0.29.0; extra == 'postgres'
44
+ Requires-Dist: psycopg>=3; extra == 'postgres'
45
45
  Provides-Extra: redis
46
46
  Requires-Dist: redis; extra == 'redis'
47
47
  Provides-Extra: spanner
48
48
  Requires-Dist: google-cloud-spanner; extra == 'spanner'
49
- Provides-Extra: sqlite
50
- Requires-Dist: aiosqlite; extra == 'sqlite'
51
49
  Description-Content-Type: text/markdown
52
50
 
53
51
  # Pytest Databases
@@ -84,7 +82,7 @@ It is designed to offer pre-configured testing setups for many different types a
84
82
 
85
83
  `pytest-databases` currently utilizes `docker compose` (or the legacy `docker-compose`) commands to manage the startup and shutdown of each database service. The following databases are currently available:
86
84
 
87
- - **Postgres**: Version 12, 13, 14, 15, and 16 are available
85
+ - **Postgres**: Version 12, 13, 14, 15, 16 and 17 are available
88
86
  - **MySQL**: Version 5.6, 5.7 and 8 are available
89
87
  - **Oracle**: Version 18c XE and 23C Free are available
90
88
  - **SQL Server**: Version 2022 is available
@@ -32,7 +32,7 @@ It is designed to offer pre-configured testing setups for many different types a
32
32
 
33
33
  `pytest-databases` currently utilizes `docker compose` (or the legacy `docker-compose`) commands to manage the startup and shutdown of each database service. The following databases are currently available:
34
34
 
35
- - **Postgres**: Version 12, 13, 14, 15, and 16 are available
35
+ - **Postgres**: Version 12, 13, 14, 15, 16 and 17 are available
36
36
  - **MySQL**: Version 5.6, 5.7 and 8 are available
37
37
  - **Oracle**: Version 18c XE and 23C Free are available
38
38
  - **SQL Server**: Version 2022 is available
@@ -12,7 +12,7 @@ license = "MIT"
12
12
  name = "pytest-databases"
13
13
  readme = "README.md"
14
14
  requires-python = ">=3.8"
15
- version = "0.8.0"
15
+ version = "0.10.0"
16
16
  #
17
17
  authors = [{ name = "Cody Fincher", email = "cody.fincher@gmail.com" }]
18
18
  keywords = [
@@ -30,6 +30,7 @@ keywords = [
30
30
  "cockroachdb",
31
31
  "redis",
32
32
  "elasticsearch",
33
+ "azure",
33
34
  ]
34
35
  # options under https://pypi.org/classifiers/
35
36
  classifiers = [
@@ -56,16 +57,15 @@ azure-storage = ["azure-storage-blob"]
56
57
  bigquery = ["google-cloud-bigquery"]
57
58
  cockroachdb = ["psycopg"]
58
59
  dragonfly = ["redis"]
59
- elasticsearch7 = ["elasticsearch7[async]"]
60
- elasticsearch8 = ["elasticsearch8[async]"]
60
+ elasticsearch7 = ["elasticsearch7"]
61
+ elasticsearch8 = ["elasticsearch8"]
61
62
  keydb = ["redis"]
62
- mssql = ["aioodbc"]
63
- mysql = ["asyncmy>=0.2.9"]
63
+ mssql = ["pymssql"]
64
+ mysql = ["pymysql"]
64
65
  oracle = ["oracledb"]
65
- postgres = ["asyncpg>=0.29.0"]
66
+ postgres = ["psycopg>=3"]
66
67
  redis = ["redis"]
67
68
  spanner = ["google-cloud-spanner"]
68
- sqlite = ["aiosqlite"]
69
69
 
70
70
 
71
71
  ######################
@@ -86,14 +86,12 @@ allow-direct-references = true
86
86
  [tool.hatch.envs.default]
87
87
  extra-dependencies = [
88
88
  # tests
89
- "anyio",
90
89
  "coverage[toml]>=6.2",
91
90
  "coverage[toml]>=6.2",
92
91
  "pytest",
93
92
  "pytest-cov",
94
93
  "pytest-mock",
95
94
  "pytest-vcr",
96
- "pytest-sugar",
97
95
  "pytest-click",
98
96
  "pytest-xdist",
99
97
  # lint
@@ -105,9 +103,9 @@ extra-dependencies = [
105
103
  "types-six",
106
104
  "types-decorator",
107
105
  "types-pyyaml",
108
- "asyncpg-stubs",
109
106
  "types-docutils",
110
107
  "types-redis",
108
+ "types-pymysql",
111
109
  # docs
112
110
  "sphinx>=7.1.2",
113
111
  "sphinx-autobuild>=2021.3.14",
@@ -127,14 +125,12 @@ python = "3.12"
127
125
  [tool.hatch.envs.test]
128
126
  extra-dependencies = [
129
127
  # tests
130
- "anyio",
131
128
  "coverage[toml]>=6.2",
132
129
  "coverage[toml]>=6.2",
133
130
  "pytest",
134
131
  "pytest-cov",
135
132
  "pytest-mock",
136
133
  "pytest-vcr",
137
- "pytest-sugar",
138
134
  "pytest-click",
139
135
  "pytest-xdist",
140
136
  # lint
@@ -146,9 +142,9 @@ extra-dependencies = [
146
142
  "types-six",
147
143
  "types-decorator",
148
144
  "types-pyyaml",
149
- "asyncpg-stubs",
150
145
  "types-docutils",
151
146
  "types-redis",
147
+ "types-pymysql",
152
148
  # docs
153
149
  "sphinx>=7.1.2",
154
150
  "sphinx-autobuild>=2021.3.14",
@@ -196,14 +192,12 @@ no-cov = "cov --no-cov"
196
192
  [tool.hatch.envs.docs]
197
193
  extra-dependencies = [
198
194
  # tests
199
- "anyio",
200
195
  "coverage[toml]>=6.2",
201
196
  "coverage[toml]>=6.2",
202
197
  "pytest",
203
198
  "pytest-cov",
204
199
  "pytest-mock",
205
200
  "pytest-vcr",
206
- "pytest-sugar",
207
201
  "pytest-click",
208
202
  "pytest-xdist",
209
203
  # lint
@@ -215,9 +209,9 @@ extra-dependencies = [
215
209
  "types-six",
216
210
  "types-decorator",
217
211
  "types-pyyaml",
218
- "asyncpg-stubs",
219
212
  "types-docutils",
220
213
  "types-redis",
214
+ "types-pymysql",
221
215
  # docs
222
216
  "sphinx>=7.1.2",
223
217
  "sphinx-autobuild>=2021.3.14",
@@ -241,6 +235,7 @@ features = [
241
235
  "elasticsearch7",
242
236
  "elasticsearch8",
243
237
  "bigquery",
238
+ "azure-storage",
244
239
  ]
245
240
  python = "3.11"
246
241
  template = "default"
@@ -261,14 +256,12 @@ build-check = ["build", "validate"]
261
256
  [tool.hatch.envs.local]
262
257
  extra-dependencies = [
263
258
  # tests
264
- "anyio",
265
259
  "coverage[toml]>=6.2",
266
260
  "coverage[toml]>=6.2",
267
261
  "pytest",
268
262
  "pytest-cov",
269
263
  "pytest-mock",
270
264
  "pytest-vcr",
271
- "pytest-sugar",
272
265
  "pytest-click",
273
266
  "pytest-xdist",
274
267
  # lint
@@ -280,9 +273,9 @@ extra-dependencies = [
280
273
  "types-six",
281
274
  "types-decorator",
282
275
  "types-pyyaml",
283
- "asyncpg-stubs",
284
276
  "types-docutils",
285
277
  "types-redis",
278
+ "types-pymysql",
286
279
  # docs
287
280
  "sphinx>=7.1.2",
288
281
  "sphinx-autobuild>=2021.3.14",
@@ -305,6 +298,7 @@ features = [
305
298
  "elasticsearch7",
306
299
  "elasticsearch8",
307
300
  "bigquery",
301
+ "azure-storage",
308
302
  ]
309
303
  path = ".venv/"
310
304
  python = "3.11"
@@ -316,14 +310,12 @@ type = "virtual"
316
310
  [tool.hatch.envs.lint]
317
311
  extra-dependencies = [
318
312
  # tests
319
- "anyio",
320
313
  "coverage[toml]>=6.2",
321
314
  "coverage[toml]>=6.2",
322
315
  "pytest",
323
316
  "pytest-cov",
324
317
  "pytest-mock",
325
318
  "pytest-vcr",
326
- "pytest-sugar",
327
319
  "pytest-click",
328
320
  "pytest-xdist",
329
321
  # lint
@@ -335,9 +327,9 @@ extra-dependencies = [
335
327
  "types-six",
336
328
  "types-decorator",
337
329
  "types-pyyaml",
338
- "asyncpg-stubs",
339
330
  "types-docutils",
340
331
  "types-redis",
332
+ "types-pymysql",
341
333
  # docs
342
334
  "sphinx>=7.1.2",
343
335
  "sphinx-autobuild>=2021.3.14",
@@ -480,7 +472,6 @@ module = ["docutils.nodes.*"]
480
472
  [[tool.mypy.overrides]]
481
473
  ignore_missing_imports = true
482
474
  module = [
483
- "asyncmy",
484
475
  "pyodbc",
485
476
  "google.auth.*",
486
477
  "google.cloud.*",
@@ -1,24 +1,26 @@
1
1
  from __future__ import annotations
2
2
 
3
- import asyncio
4
3
  import os
5
4
  import re
6
5
  import subprocess # noqa: S404
6
+ import time
7
7
  import timeit
8
+ from contextlib import AbstractContextManager
8
9
  from typing import TYPE_CHECKING, Any, Callable, Iterable
9
10
 
10
- from pytest_databases.helpers import simple_string_hash, wrap_sync
11
+ from pytest_databases.helpers import simple_string_hash
11
12
 
12
13
  if TYPE_CHECKING:
13
14
  from collections.abc import Awaitable, Generator
14
15
  from pathlib import Path
16
+ from types import TracebackType
15
17
 
16
18
  TRUE_VALUES = {"True", "true", "1", "yes", "Y", "T"}
17
19
 
18
20
 
19
- async def wait_until_responsive(
20
- check: Callable[..., Awaitable],
21
- timeout: float, # noqa: ASYNC109
21
+ def wait_until_responsive(
22
+ check: Callable[..., bool],
23
+ timeout: float,
22
24
  pause: float,
23
25
  **kwargs: Any,
24
26
  ) -> None:
@@ -33,9 +35,9 @@ async def wait_until_responsive(
33
35
  ref = timeit.default_timer()
34
36
  now = ref
35
37
  while (now - ref) < timeout: # sourcery skip
36
- if await check(**kwargs):
38
+ if check(**kwargs):
37
39
  return
38
- await asyncio.sleep(pause)
40
+ time.sleep(pause)
39
41
  now = timeit.default_timer()
40
42
 
41
43
  msg = "Timeout reached while waiting on service!"
@@ -47,7 +49,7 @@ USE_LEGACY_DOCKER_COMPOSE: bool = os.environ.get("USE_LEGACY_DOCKER_COMPOSE", "F
47
49
  COMPOSE_PROJECT_NAME: str = f"pytest-databases-{simple_string_hash(__file__)}"
48
50
 
49
51
 
50
- class DockerServiceRegistry:
52
+ class DockerServiceRegistry(AbstractContextManager):
51
53
  def __init__(
52
54
  self,
53
55
  worker_id: str,
@@ -65,6 +67,15 @@ class DockerServiceRegistry:
65
67
  )
66
68
  self._before_start = list(before_start) if before_start else []
67
69
 
70
+ def __exit__(
71
+ self,
72
+ /,
73
+ __exc_type: type[BaseException] | None,
74
+ __exc_value: BaseException | None,
75
+ __traceback: TracebackType | None,
76
+ ) -> None:
77
+ self.down()
78
+
68
79
  @staticmethod
69
80
  def _get_docker_ip() -> str:
70
81
  docker_host = os.environ.get("DOCKER_HOST", "").strip()
@@ -81,13 +92,13 @@ class DockerServiceRegistry:
81
92
  command = [*self._base_command, *self._compose_files, *args]
82
93
  subprocess.run(command, check=True, capture_output=True)
83
94
 
84
- async def start(
95
+ def start(
85
96
  self,
86
97
  name: str,
87
98
  docker_compose_files: list[Path],
88
99
  *,
89
- check: Callable[..., Any],
90
- timeout: float = 30, # noqa: ASYNC109
100
+ check: Callable[..., bool],
101
+ timeout: float = 30,
91
102
  pause: float = 0.1,
92
103
  **kwargs: Any,
93
104
  ) -> None:
@@ -101,8 +112,8 @@ class DockerServiceRegistry:
101
112
  self.run_command("up", "--force-recreate", "-d", name)
102
113
  self._running_services.add(name)
103
114
 
104
- await wait_until_responsive(
105
- check=wrap_sync(check),
115
+ wait_until_responsive(
116
+ check=check,
106
117
  timeout=timeout,
107
118
  pause=pause,
108
119
  host=self.docker_ip,
@@ -114,4 +125,4 @@ class DockerServiceRegistry:
114
125
 
115
126
  def down(self) -> None:
116
127
  if not SKIP_DOCKER_COMPOSE:
117
- self.run_command("down", "-t", "10")
128
+ self.run_command("down", "-t", "10", "--volumes")
@@ -3,9 +3,9 @@ from __future__ import annotations
3
3
  import os
4
4
  import sys
5
5
  from pathlib import Path
6
- from typing import TYPE_CHECKING, AsyncGenerator
6
+ from typing import TYPE_CHECKING
7
7
 
8
- import asyncpg
8
+ import psycopg
9
9
  import pytest
10
10
 
11
11
  from pytest_databases.docker import DockerServiceRegistry
@@ -18,9 +18,9 @@ if TYPE_CHECKING:
18
18
  COMPOSE_PROJECT_NAME: str = f"pytest-databases-alloydb-{simple_string_hash(__file__)}"
19
19
 
20
20
 
21
- async def alloydb_omni_responsive(host: str, port: int, user: str, password: str, database: str) -> bool:
21
+ def alloydb_omni_responsive(host: str, port: int, user: str, password: str, database: str) -> bool:
22
22
  try:
23
- conn = await asyncpg.connect(
23
+ conn = psycopg.connect(
24
24
  host=host,
25
25
  port=port,
26
26
  user=user,
@@ -31,10 +31,10 @@ async def alloydb_omni_responsive(host: str, port: int, user: str, password: str
31
31
  return False
32
32
 
33
33
  try:
34
- db_open = await conn.fetchrow("SELECT 1")
34
+ db_open = conn.fetchrow("SELECT 1")
35
35
  return bool(db_open is not None and db_open[0] == 1)
36
36
  finally:
37
- await conn.close()
37
+ conn.close()
38
38
 
39
39
 
40
40
  @pytest.fixture(scope="session")
@@ -49,11 +49,8 @@ def alloydb_docker_services(
49
49
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
50
50
  pytest.skip("Docker not available on this platform")
51
51
 
52
- registry = DockerServiceRegistry(worker_id, compose_project_name=alloydb_compose_project_name)
53
- try:
52
+ with DockerServiceRegistry(worker_id, compose_project_name=alloydb_compose_project_name) as registry:
54
53
  yield registry
55
- finally:
56
- registry.down()
57
54
 
58
55
 
59
56
  @pytest.fixture(scope="session")
@@ -93,7 +90,7 @@ def alloydb_docker_ip(alloydb_docker_services: DockerServiceRegistry) -> str:
93
90
 
94
91
  # alias to the latest
95
92
  @pytest.fixture(autouse=False, scope="session")
96
- async def alloydb_omni_service(
93
+ def alloydb_omni_service(
97
94
  alloydb_docker_services: DockerServiceRegistry,
98
95
  default_alloydb_omni_service_name: str,
99
96
  alloydb_docker_compose_files: list[Path],
@@ -101,12 +98,12 @@ async def alloydb_omni_service(
101
98
  postgres_database: str,
102
99
  postgres_user: str,
103
100
  postgres_password: str,
104
- ) -> AsyncGenerator[None, None]:
101
+ ) -> Generator[None, None, None]:
105
102
  os.environ["POSTGRES_PASSWORD"] = postgres_password
106
103
  os.environ["POSTGRES_USER"] = postgres_user
107
104
  os.environ["POSTGRES_DATABASE"] = postgres_database
108
105
  os.environ[f"{default_alloydb_omni_service_name.upper()}_PORT"] = str(alloydb_omni_port)
109
- await alloydb_docker_services.start(
106
+ alloydb_docker_services.start(
110
107
  name=default_alloydb_omni_service_name,
111
108
  docker_compose_files=alloydb_docker_compose_files,
112
109
  timeout=45,
@@ -121,22 +118,19 @@ async def alloydb_omni_service(
121
118
 
122
119
 
123
120
  @pytest.fixture(autouse=False, scope="session")
124
- async def alloydb_omni_startup_connection(
121
+ def alloydb_omni_startup_connection(
125
122
  alloydb_omni_service: DockerServiceRegistry,
126
123
  alloydb_docker_ip: str,
127
124
  alloydb_omni_port: int,
128
125
  postgres_database: str,
129
126
  postgres_user: str,
130
127
  postgres_password: str,
131
- ) -> AsyncGenerator[asyncpg.Connection[asyncpg.Record], None]:
132
- conn = await asyncpg.connect(
128
+ ) -> Generator[psycopg.Connection, None, None]:
129
+ with psycopg.connect(
133
130
  host=alloydb_docker_ip,
134
131
  port=alloydb_omni_port,
135
132
  user=postgres_user,
136
133
  database=postgres_database,
137
134
  password=postgres_password,
138
- )
139
- try:
135
+ ) as conn:
140
136
  yield conn
141
- finally:
142
- await conn.close()
@@ -62,14 +62,11 @@ def azure_blob_docker_services(
62
62
  azure_blob_service_startup_delay: int,
63
63
  worker_id: str = "main",
64
64
  ) -> Generator[DockerServiceRegistry, None, None]:
65
- registry = DockerServiceRegistry(
65
+ with DockerServiceRegistry(
66
66
  worker_id,
67
67
  compose_project_name=azure_blob_compose_project_name,
68
- )
69
- try:
68
+ ) as registry:
70
69
  yield registry
71
- finally:
72
- registry.down()
73
70
 
74
71
 
75
72
  @pytest.fixture(scope="session")
@@ -140,14 +137,14 @@ async def azure_blob_async_container_client(
140
137
 
141
138
 
142
139
  @pytest.fixture(autouse=False, scope="session")
143
- async def azure_blob_service(
140
+ def azure_blob_service(
144
141
  azure_blob_docker_services: DockerServiceRegistry,
145
142
  default_azure_blob_redis_service_name: str,
146
143
  azure_blob_docker_compose_files: list[Path],
147
144
  azure_blob_connection_string: str,
148
145
  azure_blob_port: int,
149
146
  azure_blob_default_container_name: str,
150
- ) -> AsyncGenerator[None, None]:
147
+ ) -> Generator[None, None, None]:
151
148
  os.environ["AZURE_BLOB_PORT"] = str(azure_blob_port)
152
149
 
153
150
  def azurite_responsive(host: str, port: int) -> bool:
@@ -157,7 +154,7 @@ async def azure_blob_service(
157
154
  logs = _get_container_logs(str(azure_blob_docker_compose_files[0].absolute()))
158
155
  return "Azurite Blob service successfully listens on" in logs
159
156
 
160
- await azure_blob_docker_services.start(
157
+ azure_blob_docker_services.start(
161
158
  name=default_azure_blob_redis_service_name,
162
159
  docker_compose_files=azure_blob_docker_compose_files,
163
160
  check=azurite_responsive,
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import os
4
4
  import sys
5
5
  from pathlib import Path
6
- from typing import TYPE_CHECKING, AsyncGenerator
6
+ from typing import TYPE_CHECKING
7
7
 
8
8
  import pytest
9
9
  from google.api_core.client_options import ClientOptions
@@ -20,7 +20,7 @@ if TYPE_CHECKING:
20
20
  COMPOSE_PROJECT_NAME: str = f"pytest-databases-bigquery-{simple_string_hash(__file__)}"
21
21
 
22
22
 
23
- async def bigquery_responsive(
23
+ def bigquery_responsive(
24
24
  host: str,
25
25
  bigquery_endpoint: str,
26
26
  bigquery_dataset: str,
@@ -53,11 +53,8 @@ def bigquery_docker_services(
53
53
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
54
54
  pytest.skip("Docker not available on this platform")
55
55
 
56
- registry = DockerServiceRegistry(worker_id, compose_project_name=bigquery_compose_project_name)
57
- try:
56
+ with DockerServiceRegistry(worker_id, compose_project_name=bigquery_compose_project_name) as registry:
58
57
  yield registry
59
- finally:
60
- registry.down()
61
58
 
62
59
 
63
60
  @pytest.fixture(scope="session")
@@ -111,7 +108,7 @@ def bigquery_endpoint(bigquery_docker_ip: str, bigquery_port: int) -> str:
111
108
 
112
109
 
113
110
  @pytest.fixture(autouse=False, scope="session")
114
- async def bigquery_service(
111
+ def bigquery_service(
115
112
  bigquery_docker_services: DockerServiceRegistry,
116
113
  default_bigquery_service_name: str,
117
114
  bigquery_docker_compose_files: list[Path],
@@ -122,13 +119,13 @@ async def bigquery_service(
122
119
  bigquery_project: str,
123
120
  bigquery_credentials: Credentials,
124
121
  bigquery_client_options: ClientOptions,
125
- ) -> AsyncGenerator[None, None]:
122
+ ) -> Generator[None, None, None]:
126
123
  os.environ["BIGQUERY_ENDPOINT"] = bigquery_endpoint
127
124
  os.environ["BIGQUERY_DATASET"] = bigquery_dataset
128
125
  os.environ["BIGQUERY_PORT"] = str(bigquery_port)
129
126
  os.environ["BIGQUERY_GRPC_PORT"] = str(bigquery_grpc_port)
130
127
  os.environ["GOOGLE_CLOUD_PROJECT"] = bigquery_project
131
- await bigquery_docker_services.start(
128
+ bigquery_docker_services.start(
132
129
  name=default_bigquery_service_name,
133
130
  docker_compose_files=bigquery_docker_compose_files,
134
131
  timeout=60,
@@ -143,12 +140,12 @@ async def bigquery_service(
143
140
 
144
141
 
145
142
  @pytest.fixture(autouse=False, scope="session")
146
- async def bigquery_startup_connection(
143
+ def bigquery_startup_connection(
147
144
  bigquery_service: DockerServiceRegistry,
148
145
  bigquery_project: str,
149
146
  bigquery_credentials: Credentials,
150
147
  bigquery_client_options: ClientOptions,
151
- ) -> AsyncGenerator[bigquery.Client, None]:
148
+ ) -> Generator[bigquery.Client, None, None]:
152
149
  yield bigquery.Client(
153
150
  project=bigquery_project, client_options=bigquery_client_options, credentials=bigquery_credentials
154
151
  )
@@ -3,9 +3,9 @@ from __future__ import annotations
3
3
  import os
4
4
  import sys
5
5
  from pathlib import Path
6
- from typing import TYPE_CHECKING, AsyncGenerator
6
+ from typing import TYPE_CHECKING
7
7
 
8
- import asyncpg
8
+ import psycopg
9
9
  import pytest
10
10
 
11
11
  from pytest_databases.docker import DockerServiceRegistry
@@ -18,18 +18,18 @@ if TYPE_CHECKING:
18
18
  COMPOSE_PROJECT_NAME: str = f"pytest-databases-cockroachdb-{simple_string_hash(__file__)}"
19
19
 
20
20
 
21
- async def cockroachdb_responsive(host: str, port: int, database: str, driver_opts: dict[str, str]) -> bool:
21
+ def cockroachdb_responsive(host: str, port: int, database: str, driver_opts: dict[str, str]) -> bool:
22
22
  opts = "&".join(f"{k}={v}" for k, v in driver_opts.items()) if driver_opts else ""
23
23
  try:
24
- conn = await asyncpg.connect(f"postgresql://root@{host}:{port}/{database}?{opts}")
24
+ conn = psycopg.connect(f"postgresql://root@{host}:{port}/{database}?{opts}")
25
25
  except Exception: # noqa: BLE001
26
26
  return False
27
27
 
28
28
  try:
29
- db_open = await conn.fetchrow("SELECT 1")
29
+ db_open = conn.execute("SELECT 1").fetchone()
30
30
  return bool(db_open is not None and db_open[0] == 1)
31
31
  finally:
32
- await conn.close()
32
+ conn.close()
33
33
 
34
34
 
35
35
  @pytest.fixture(scope="session")
@@ -44,11 +44,8 @@ def cockroachdb_docker_services(
44
44
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
45
45
  pytest.skip("Docker not available on this platform")
46
46
 
47
- registry = DockerServiceRegistry(worker_id, compose_project_name=cockroachdb_compose_project_name)
48
- try:
47
+ with DockerServiceRegistry(worker_id, compose_project_name=cockroachdb_compose_project_name) as registry:
49
48
  yield registry
50
- finally:
51
- registry.down()
52
49
 
53
50
 
54
51
  @pytest.fixture(scope="session")
@@ -82,17 +79,17 @@ def cockroachdb_docker_ip(cockroachdb_docker_services: DockerServiceRegistry) ->
82
79
 
83
80
 
84
81
  @pytest.fixture(autouse=False, scope="session")
85
- async def cockroachdb_service(
82
+ def cockroachdb_service(
86
83
  cockroachdb_docker_services: DockerServiceRegistry,
87
84
  default_cockroachdb_service_name: str,
88
85
  cockroachdb_docker_compose_files: list[Path],
89
86
  cockroachdb_port: int,
90
87
  cockroachdb_database: str,
91
88
  cockroachdb_driver_opts: dict[str, str],
92
- ) -> AsyncGenerator[None, None]:
89
+ ) -> Generator[None, None, None]:
93
90
  os.environ["COCKROACHDB_DATABASE"] = cockroachdb_database
94
91
  os.environ["COCKROACHDB_PORT"] = str(cockroachdb_port)
95
- await cockroachdb_docker_services.start(
92
+ cockroachdb_docker_services.start(
96
93
  name=default_cockroachdb_service_name,
97
94
  docker_compose_files=cockroachdb_docker_compose_files,
98
95
  timeout=60,
@@ -106,18 +103,15 @@ async def cockroachdb_service(
106
103
 
107
104
 
108
105
  @pytest.fixture(autouse=False, scope="session")
109
- async def cockroachdb_startup_connection(
106
+ def cockroachdb_startup_connection(
110
107
  cockroachdb_service: DockerServiceRegistry,
111
108
  cockroachdb_docker_ip: str,
112
109
  cockroachdb_port: int,
113
110
  cockroachdb_database: str,
114
111
  cockroachdb_driver_opts: dict[str, str],
115
- ) -> AsyncGenerator[asyncpg.Connection[asyncpg.Record], None]:
112
+ ) -> Generator[psycopg.Connection, None, None]:
116
113
  opts = "&".join(f"{k}={v}" for k, v in cockroachdb_driver_opts.items()) if cockroachdb_driver_opts else ""
117
- conn = await asyncpg.connect(
114
+ with psycopg.connect(
118
115
  f"postgresql://root@{cockroachdb_docker_ip}:{cockroachdb_port}/{cockroachdb_database}?{opts}"
119
- )
120
- try:
116
+ ) as conn:
121
117
  yield conn
122
- finally:
123
- await conn.close()
@@ -39,6 +39,14 @@ services:
39
39
  - "${POSTGRES16_PORT:-5427}:5432" # use a non-standard port here
40
40
  environment:
41
41
  POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-super-secret}
42
+ postgres17:
43
+ networks:
44
+ - default
45
+ image: postgres:17
46
+ ports:
47
+ - "${POSTGRES17_PORT:-5428}:5432" # use a non-standard port here
48
+ environment:
49
+ POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-super-secret}
42
50
  networks:
43
51
  default:
44
52
  driver: bridge