pytest-databases 0.9.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 (70) hide show
  1. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/PKG-INFO +2 -2
  2. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/README.md +1 -1
  3. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/pyproject.toml +1 -1
  4. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/__init__.py +13 -2
  5. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/alloydb_omni.py +1 -4
  6. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/azure_blob.py +2 -5
  7. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/bigquery.py +1 -4
  8. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/cockroachdb.py +1 -4
  9. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.postgres.yml +8 -0
  10. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/dragonfly.py +1 -4
  11. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/elastic_search.py +1 -4
  12. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/keydb.py +1 -4
  13. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/mariadb.py +1 -4
  14. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/mssql.py +1 -4
  15. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/mysql.py +1 -4
  16. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/oracle.py +1 -4
  17. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/postgres.py +65 -18
  18. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/redis.py +1 -4
  19. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/spanner.py +1 -4
  20. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/valkey.py +1 -4
  21. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_postgres.py +35 -2
  22. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/.gitignore +0 -0
  23. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/.pre-commit-config.yaml +0 -0
  24. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/.sourcery.yaml +0 -0
  25. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/.vscode/launch.json +0 -0
  26. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/.vscode/settings.json +0 -0
  27. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/CODEOWNERS +0 -0
  28. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/CONTRIBUTING.rst +0 -0
  29. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/LICENSE +0 -0
  30. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/Makefile +0 -0
  31. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/scripts/__init__.py +0 -0
  32. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/scripts/build_docs.py +0 -0
  33. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/scripts/convert_docs.sh +0 -0
  34. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/scripts/install-hatch.sh +0 -0
  35. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/sonar-project.properties +0 -0
  36. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/__init__.py +0 -0
  37. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/__metadata__.py +0 -0
  38. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.alloydb-omni.yml +0 -0
  39. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.azurite.yml +0 -0
  40. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.bigquery.yml +0 -0
  41. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.cockroachdb.yml +0 -0
  42. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.dragonfly.yml +0 -0
  43. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.elasticsearch.yml +0 -0
  44. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.keydb.yml +0 -0
  45. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.mariadb.yml +0 -0
  46. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.mssql.yml +0 -0
  47. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.mysql.yml +0 -0
  48. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.oracle.yml +0 -0
  49. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.redis.yml +0 -0
  50. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.spanner.yml +0 -0
  51. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/docker/docker-compose.valkey.yml +0 -0
  52. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/helpers.py +0 -0
  53. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/src/pytest_databases/py.typed +0 -0
  54. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/__init__.py +0 -0
  55. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/conftest.py +0 -0
  56. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/__init__.py +0 -0
  57. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_alloydb_omni.py +0 -0
  58. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_azure_blob.py +0 -0
  59. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_bigquery.py +0 -0
  60. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_cockroachdb.py +0 -0
  61. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_dragonfly.py +0 -0
  62. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_elasticsearch.py +0 -0
  63. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_keydb.py +0 -0
  64. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_mariadb.py +0 -0
  65. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_mssql.py +0 -0
  66. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_mysql.py +0 -0
  67. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_oracle.py +0 -0
  68. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_redis.py +0 -0
  69. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_spanner.py +0 -0
  70. {pytest_databases-0.9.0 → pytest_databases-0.10.0}/tests/docker/test_valkey.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pytest-databases
3
- Version: 0.9.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
@@ -82,7 +82,7 @@ It is designed to offer pre-configured testing setups for many different types a
82
82
 
83
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:
84
84
 
85
- - **Postgres**: Version 12, 13, 14, 15, and 16 are available
85
+ - **Postgres**: Version 12, 13, 14, 15, 16 and 17 are available
86
86
  - **MySQL**: Version 5.6, 5.7 and 8 are available
87
87
  - **Oracle**: Version 18c XE and 23C Free are available
88
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.9.0"
15
+ version = "0.10.0"
16
16
  #
17
17
  authors = [{ name = "Cody Fincher", email = "cody.fincher@gmail.com" }]
18
18
  keywords = [
@@ -5,6 +5,7 @@ import re
5
5
  import subprocess # noqa: S404
6
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
11
  from pytest_databases.helpers import simple_string_hash
@@ -12,6 +13,7 @@ from pytest_databases.helpers import simple_string_hash
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
 
@@ -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()
@@ -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")
@@ -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")
@@ -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")
@@ -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")
@@ -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")
@@ -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
@@ -29,11 +29,8 @@ def dragonfly_docker_services(
29
29
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
30
30
  pytest.skip("Docker not available on this platform")
31
31
 
32
- registry = DockerServiceRegistry(worker_id, compose_project_name=dragonfly_compose_project_name)
33
- try:
32
+ with DockerServiceRegistry(worker_id, compose_project_name=dragonfly_compose_project_name) as registry:
34
33
  yield registry
35
- finally:
36
- registry.down()
37
34
 
38
35
 
39
36
  @pytest.fixture(scope="session")
@@ -51,11 +51,8 @@ def elasticsearch_docker_services(
51
51
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
52
52
  pytest.skip("Docker not available on this platform")
53
53
 
54
- registry = DockerServiceRegistry(worker_id, compose_project_name=elasticsearch_compose_project_name)
55
- try:
54
+ with DockerServiceRegistry(worker_id, compose_project_name=elasticsearch_compose_project_name) as registry:
56
55
  yield registry
57
- finally:
58
- registry.down()
59
56
 
60
57
 
61
58
  @pytest.fixture(scope="session")
@@ -30,11 +30,8 @@ def keydb_docker_services(
30
30
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
31
31
  pytest.skip("Docker not available on this platform")
32
32
 
33
- registry = DockerServiceRegistry(worker_id, compose_project_name=keydb_compose_project_name)
34
- try:
33
+ with DockerServiceRegistry(worker_id, compose_project_name=keydb_compose_project_name) as registry:
35
34
  yield registry
36
- finally:
37
- registry.down()
38
35
 
39
36
 
40
37
  @pytest.fixture(scope="session")
@@ -31,11 +31,8 @@ def mariadb_docker_services(
31
31
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
32
32
  pytest.skip("Docker not available on this platform")
33
33
 
34
- registry = DockerServiceRegistry(worker_id, compose_project_name=mariadb_compose_project_name)
35
- try:
34
+ with DockerServiceRegistry(worker_id, compose_project_name=mariadb_compose_project_name) as registry:
36
35
  yield registry
37
- finally:
38
- registry.down()
39
36
 
40
37
 
41
38
  @pytest.fixture(scope="session")
@@ -48,11 +48,8 @@ def mssql_docker_services(
48
48
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
49
49
  pytest.skip("Docker not available on this platform")
50
50
 
51
- registry = DockerServiceRegistry(worker_id, compose_project_name=mssql_compose_project_name)
52
- try:
51
+ with DockerServiceRegistry(worker_id, compose_project_name=mssql_compose_project_name) as registry:
53
52
  yield registry
54
- finally:
55
- registry.down()
56
53
 
57
54
 
58
55
  @pytest.fixture(scope="session")
@@ -53,11 +53,8 @@ def mysql_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=mysql_compose_project_name)
57
- try:
56
+ with DockerServiceRegistry(worker_id, compose_project_name=mysql_compose_project_name) as registry:
58
57
  yield registry
59
- finally:
60
- registry.down()
61
58
 
62
59
 
63
60
  @pytest.fixture(scope="session")
@@ -47,11 +47,8 @@ def oracle_docker_services(
47
47
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
48
48
  pytest.skip("Docker not available on this platform")
49
49
 
50
- registry = DockerServiceRegistry(worker_id, compose_project_name=oracle_compose_project_name)
51
- try:
50
+ with DockerServiceRegistry(worker_id, compose_project_name=oracle_compose_project_name) as registry:
52
51
  yield registry
53
- finally:
54
- registry.down()
55
52
 
56
53
 
57
54
  @pytest.fixture(scope="session")
@@ -45,11 +45,8 @@ def postgres_docker_services(
45
45
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
46
46
  pytest.skip("Docker not available on this platform")
47
47
 
48
- registry = DockerServiceRegistry(worker_id, compose_project_name=postgres_compose_project_name)
49
- try:
48
+ with DockerServiceRegistry(worker_id, compose_project_name=postgres_compose_project_name) as registry:
50
49
  yield registry
51
- finally:
52
- registry.down()
53
50
 
54
51
 
55
52
  @pytest.fixture(scope="session")
@@ -96,15 +93,19 @@ def postgres15_port() -> int:
96
93
  def postgres16_port() -> int:
97
94
  return 5427
98
95
 
96
+ @pytest.fixture(scope="session")
97
+ def postgres17_port() -> int:
98
+ return 5428
99
+
99
100
 
100
101
  @pytest.fixture(scope="session")
101
102
  def default_postgres_service_name() -> str:
102
- return "postgres16"
103
+ return "postgres17"
103
104
 
104
105
 
105
106
  @pytest.fixture(scope="session")
106
- def postgres_port(postgres16_port: int) -> int:
107
- return postgres16_port
107
+ def postgres_port(postgres17_port: int) -> int:
108
+ return postgres17_port
108
109
 
109
110
 
110
111
  @pytest.fixture(scope="session")
@@ -125,7 +126,7 @@ def postgres12_service(
125
126
  postgres_database: str,
126
127
  postgres_user: str,
127
128
  postgres_password: str,
128
- ) -> Generator[DockerServiceRegistry, None, None]:
129
+ ) -> DockerServiceRegistry:
129
130
  os.environ["POSTGRES_PASSWORD"] = postgres_password
130
131
  os.environ["POSTGRES_USER"] = postgres_user
131
132
  os.environ["POSTGRES_DATABASE"] = postgres_database
@@ -141,7 +142,7 @@ def postgres12_service(
141
142
  user=postgres_user,
142
143
  password=postgres_password,
143
144
  )
144
- yield postgres_docker_services
145
+ return postgres_docker_services
145
146
 
146
147
 
147
148
  @pytest.fixture(autouse=False, scope="session")
@@ -152,7 +153,7 @@ def postgres13_service(
152
153
  postgres_database: str,
153
154
  postgres_user: str,
154
155
  postgres_password: str,
155
- ) -> Generator[DockerServiceRegistry, None, None]:
156
+ ) -> DockerServiceRegistry:
156
157
  os.environ["POSTGRES_PASSWORD"] = postgres_password
157
158
  os.environ["POSTGRES_USER"] = postgres_user
158
159
  os.environ["POSTGRES_DATABASE"] = postgres_database
@@ -168,7 +169,7 @@ def postgres13_service(
168
169
  user=postgres_user,
169
170
  password=postgres_password,
170
171
  )
171
- yield postgres_docker_services
172
+ return postgres_docker_services
172
173
 
173
174
 
174
175
  @pytest.fixture(autouse=False, scope="session")
@@ -179,7 +180,7 @@ def postgres14_service(
179
180
  postgres_database: str,
180
181
  postgres_user: str,
181
182
  postgres_password: str,
182
- ) -> Generator[DockerServiceRegistry, None, None]:
183
+ ) -> DockerServiceRegistry:
183
184
  os.environ["POSTGRES_PASSWORD"] = postgres_password
184
185
  os.environ["POSTGRES_USER"] = postgres_user
185
186
  os.environ["POSTGRES_DATABASE"] = postgres_database
@@ -195,7 +196,7 @@ def postgres14_service(
195
196
  user=postgres_user,
196
197
  password=postgres_password,
197
198
  )
198
- yield postgres_docker_services
199
+ return postgres_docker_services
199
200
 
200
201
 
201
202
  @pytest.fixture(autouse=False, scope="session")
@@ -206,7 +207,7 @@ def postgres15_service(
206
207
  postgres_database: str,
207
208
  postgres_user: str,
208
209
  postgres_password: str,
209
- ) -> Generator[DockerServiceRegistry, None, None]:
210
+ ) -> DockerServiceRegistry:
210
211
  os.environ["POSTGRES_PASSWORD"] = postgres_password
211
212
  os.environ["POSTGRES_USER"] = postgres_user
212
213
  os.environ["POSTGRES_DATABASE"] = postgres_database
@@ -222,7 +223,7 @@ def postgres15_service(
222
223
  user=postgres_user,
223
224
  password=postgres_password,
224
225
  )
225
- yield postgres_docker_services
226
+ return postgres_docker_services
226
227
 
227
228
 
228
229
  @pytest.fixture(autouse=False, scope="session")
@@ -233,7 +234,7 @@ def postgres16_service(
233
234
  postgres_database: str,
234
235
  postgres_user: str,
235
236
  postgres_password: str,
236
- ) -> Generator[DockerServiceRegistry, None, None]:
237
+ ) -> DockerServiceRegistry:
237
238
  os.environ["POSTGRES_PASSWORD"] = postgres_password
238
239
  os.environ["POSTGRES_USER"] = postgres_user
239
240
  os.environ["POSTGRES_DATABASE"] = postgres_database
@@ -249,6 +250,33 @@ def postgres16_service(
249
250
  user=postgres_user,
250
251
  password=postgres_password,
251
252
  )
253
+ return postgres_docker_services
254
+
255
+
256
+ @pytest.fixture(autouse=False, scope="session")
257
+ def postgres17_service(
258
+ postgres_docker_services: DockerServiceRegistry,
259
+ postgres_docker_compose_files: list[Path],
260
+ postgres17_port: int,
261
+ postgres_database: str,
262
+ postgres_user: str,
263
+ postgres_password: str,
264
+ ) -> Generator[DockerServiceRegistry, None, None]:
265
+ os.environ["POSTGRES_PASSWORD"] = postgres_password
266
+ os.environ["POSTGRES_USER"] = postgres_user
267
+ os.environ["POSTGRES_DATABASE"] = postgres_database
268
+ os.environ["POSTGRES17_PORT"] = str(postgres17_port)
269
+ postgres_docker_services.start(
270
+ "postgres17",
271
+ docker_compose_files=postgres_docker_compose_files,
272
+ timeout=45,
273
+ pause=1,
274
+ check=postgres_responsive,
275
+ port=postgres17_port,
276
+ database=postgres_database,
277
+ user=postgres_user,
278
+ password=postgres_password,
279
+ )
252
280
  yield postgres_docker_services
253
281
 
254
282
 
@@ -262,7 +290,7 @@ def postgres_service(
262
290
  postgres_database: str,
263
291
  postgres_user: str,
264
292
  postgres_password: str,
265
- ) -> Generator[DockerServiceRegistry, None, None]:
293
+ ) -> DockerServiceRegistry:
266
294
  os.environ["POSTGRES_PASSWORD"] = postgres_password
267
295
  os.environ["POSTGRES_USER"] = postgres_user
268
296
  os.environ["POSTGRES_DATABASE"] = postgres_database
@@ -278,7 +306,7 @@ def postgres_service(
278
306
  user=postgres_user,
279
307
  password=postgres_password,
280
308
  )
281
- yield postgres_docker_services
309
+ return postgres_docker_services
282
310
 
283
311
 
284
312
  @pytest.fixture(autouse=False, scope="session")
@@ -301,6 +329,25 @@ def postgres_startup_connection(
301
329
  ) as conn:
302
330
  yield conn
303
331
 
332
+ @pytest.fixture(autouse=False, scope="session")
333
+ def postgres17_startup_connection(
334
+ postgres17_service: DockerServiceRegistry,
335
+ postgres_docker_ip: str,
336
+ postgres17_port: int,
337
+ postgres_database: str,
338
+ postgres_user: str,
339
+ postgres_password: str,
340
+ ) -> Generator[psycopg.Connection, None, None]:
341
+ with psycopg.connect(
342
+ _make_connection_string(
343
+ host=postgres_docker_ip,
344
+ port=postgres17_port,
345
+ user=postgres_user,
346
+ password=postgres_password,
347
+ database=postgres_database,
348
+ ),
349
+ ) as conn:
350
+ yield conn
304
351
 
305
352
  @pytest.fixture(autouse=False, scope="session")
306
353
  def postgres16_startup_connection(
@@ -41,11 +41,8 @@ def redis_docker_services(
41
41
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
42
42
  pytest.skip("Docker not available on this platform")
43
43
 
44
- registry = DockerServiceRegistry(worker_id, compose_project_name=redis_compose_project_name)
45
- try:
44
+ with DockerServiceRegistry(worker_id, compose_project_name=redis_compose_project_name) as registry:
46
45
  yield registry
47
- finally:
48
- registry.down()
49
46
 
50
47
 
51
48
  @pytest.fixture(scope="session")
@@ -57,11 +57,8 @@ def spanner_docker_services(
57
57
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
58
58
  pytest.skip("Docker not available on this platform")
59
59
 
60
- registry = DockerServiceRegistry(worker_id, compose_project_name=spanner_compose_project_name)
61
- try:
60
+ with DockerServiceRegistry(worker_id, compose_project_name=spanner_compose_project_name) as registry:
62
61
  yield registry
63
- finally:
64
- registry.down()
65
62
 
66
63
 
67
64
  @pytest.fixture(scope="session")
@@ -30,11 +30,8 @@ def valkey_docker_services(
30
30
  if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
31
31
  pytest.skip("Docker not available on this platform")
32
32
 
33
- registry = DockerServiceRegistry(worker_id, compose_project_name=valkey_compose_project_name)
34
- try:
33
+ with DockerServiceRegistry(worker_id, compose_project_name=valkey_compose_project_name) as registry:
35
34
  yield registry
36
- finally:
37
- registry.down()
38
35
 
39
36
 
40
37
  @pytest.fixture(scope="session")
@@ -21,8 +21,8 @@ def test_postgres_default_config(
21
21
  postgres_user: str,
22
22
  postgres_password: str,
23
23
  ) -> None:
24
- assert default_postgres_service_name == "postgres16"
25
- assert postgres_port == 5427
24
+ assert default_postgres_service_name == "postgres17"
25
+ assert postgres_port == 5428
26
26
  assert postgres_database == "postgres"
27
27
  assert postgres_user == "postgres"
28
28
  assert postgres_password == "super-secret"
@@ -87,6 +87,16 @@ def test_postgres_16_config(
87
87
  assert postgres_user == "postgres"
88
88
  assert postgres_password == "super-secret"
89
89
 
90
+ def test_postgres_17_config(
91
+ postgres17_port: int,
92
+ postgres_database: str,
93
+ postgres_user: str,
94
+ postgres_password: str,
95
+ ) -> None:
96
+ assert postgres17_port == 5428
97
+ assert postgres_database == "postgres"
98
+ assert postgres_user == "postgres"
99
+ assert postgres_password == "super-secret"
90
100
 
91
101
  def test_postgres_services(
92
102
  postgres_docker_ip: str,
@@ -195,6 +205,29 @@ def test_postgres_16_services(
195
205
  )
196
206
  assert ping
197
207
 
208
+ def test_postgres_17_services(
209
+ postgres_docker_ip: str,
210
+ postgres17_service: DockerServiceRegistry,
211
+ postgres17_port: int,
212
+ postgres_database: str,
213
+ postgres_user: str,
214
+ postgres_password: str,
215
+ ) -> None:
216
+ ping = postgres_responsive(
217
+ postgres_docker_ip,
218
+ port=postgres17_port,
219
+ database=postgres_database,
220
+ user=postgres_user,
221
+ password=postgres_password,
222
+ )
223
+ assert ping
224
+
225
+ def test_postgres_17_services_after_start(
226
+ postgres17_startup_connection: psycopg.Connection,
227
+ ) -> None:
228
+ postgres17_startup_connection.execute("CREATE TABLE if not exists simple_table as SELECT 1")
229
+ result = postgres17_startup_connection.execute("select * from simple_table").fetchone()
230
+ assert bool(result is not None and result[0] == 1)
198
231
 
199
232
  def test_postgres_16_services_after_start(
200
233
  postgres16_startup_connection: psycopg.Connection,