pytest-databases 0.14.1__tar.gz → 0.15.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 (90) hide show
  1. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.github/workflows/ci.yaml +3 -3
  2. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.github/workflows/docs.yml +1 -1
  3. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.pre-commit-config.yaml +2 -2
  4. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/PKG-INFO +2 -2
  5. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/README.md +1 -1
  6. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/postgres.rst +7 -6
  7. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/pyproject.toml +5 -5
  8. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/_service.py +20 -4
  9. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/postgres.py +37 -1
  10. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_postgres.py +2 -0
  11. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_redis.py +2 -2
  12. pytest_databases-0.15.0/uv.lock +3761 -0
  13. pytest_databases-0.14.1/uv.lock +0 -3461
  14. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.github/CODEOWNERS +0 -0
  15. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.github/dependabot.yaml +0 -0
  16. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.github/workflows/cd.yaml +0 -0
  17. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.github/workflows/pr-title.yaml +0 -0
  18. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.github/workflows/release.yaml +0 -0
  19. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.gitignore +0 -0
  20. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.sourcery.yaml +0 -0
  21. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.vscode/launch.json +0 -0
  22. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/.vscode/settings.json +0 -0
  23. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/CODEOWNERS +0 -0
  24. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/CONTRIBUTING.rst +0 -0
  25. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/LICENSE +0 -0
  26. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/Makefile +0 -0
  27. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/.gitignore +0 -0
  28. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/__init__.py +0 -0
  29. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/_static/.gitkeep +0 -0
  30. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/_static/custom.css +0 -0
  31. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/_static/logo.svg +0 -0
  32. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/changelog.rst +0 -0
  33. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/conf.py +0 -0
  34. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/contribution-guide.rst +0 -0
  35. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/getting-started/basic-usage.rst +0 -0
  36. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/getting-started/configuration.rst +0 -0
  37. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/getting-started/enabling-plugins.rst +0 -0
  38. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/getting-started/index.rst +0 -0
  39. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/getting-started/installation.rst +0 -0
  40. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/getting-started/next-steps.rst +0 -0
  41. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/index.rst +0 -0
  42. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/azure_blob_storage.rst +0 -0
  43. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/bigquery.rst +0 -0
  44. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/cockroachdb.rst +0 -0
  45. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/elasticsearch.rst +0 -0
  46. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/index.rst +0 -0
  47. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/mariadb.rst +0 -0
  48. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/minio.rst +0 -0
  49. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/mysql.rst +0 -0
  50. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/oracle.rst +0 -0
  51. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/redis.rst +0 -0
  52. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/spanner.rst +0 -0
  53. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/sqlserver.rst +0 -0
  54. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/docs/supported-databases/valkey.rst +0 -0
  55. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/scripts/__init__.py +0 -0
  56. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/scripts/build_docs.py +0 -0
  57. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/scripts/convert_docs.sh +0 -0
  58. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/scripts/install-hatch.sh +0 -0
  59. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/sonar-project.properties +0 -0
  60. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/__init__.py +0 -0
  61. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/__metadata__.py +0 -0
  62. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/__init__.py +0 -0
  63. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/azure_blob.py +0 -0
  64. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/bigquery.py +0 -0
  65. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/cockroachdb.py +0 -0
  66. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/elastic_search.py +0 -0
  67. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/mariadb.py +0 -0
  68. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/minio.py +0 -0
  69. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/mssql.py +0 -0
  70. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/mysql.py +0 -0
  71. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/oracle.py +0 -0
  72. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/redis.py +0 -0
  73. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/spanner.py +0 -0
  74. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/docker/valkey.py +0 -0
  75. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/helpers.py +0 -0
  76. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/py.typed +0 -0
  77. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/src/pytest_databases/types.py +0 -0
  78. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/__init__.py +0 -0
  79. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/conftest.py +0 -0
  80. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_azure_blob.py +0 -0
  81. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_bigquery.py +0 -0
  82. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_cockroachdb.py +0 -0
  83. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_elasticsearch.py +0 -0
  84. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_mariadb.py +0 -0
  85. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_minio.py +0 -0
  86. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_mssql.py +0 -0
  87. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_mysql.py +0 -0
  88. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_oracle.py +0 -0
  89. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_spanner.py +0 -0
  90. {pytest_databases-0.14.1 → pytest_databases-0.15.0}/tests/test_valkey.py +0 -0
@@ -32,7 +32,7 @@ jobs:
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
33
33
 
34
34
  - name: Set up Python ${{ matrix.python-version }}
35
- uses: actions/setup-python@v5
35
+ uses: actions/setup-python@v6
36
36
  with:
37
37
  python-version: ${{ matrix.python-version }}
38
38
 
@@ -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.5.0
61
+ uses: codecov/codecov-action@v5.5.1
62
62
  with:
63
63
  token: ${{ secrets.CODECOV_TOKEN }}
64
64
  slug: litestar-org/pytest-databases
@@ -73,7 +73,7 @@ jobs:
73
73
  - uses: actions/checkout@v5
74
74
 
75
75
  - name: Set up Python
76
- uses: actions/setup-python@v5
76
+ uses: actions/setup-python@v6
77
77
  with:
78
78
  python-version: 3.9
79
79
 
@@ -26,7 +26,7 @@ jobs:
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
27
27
 
28
28
  - name: Set up Python ${{ matrix.python-version }}
29
- uses: actions/setup-python@v5
29
+ uses: actions/setup-python@v6
30
30
  with:
31
31
  python-version: 3.12
32
32
 
@@ -2,7 +2,7 @@ exclude: "^docs/conf.py"
2
2
 
3
3
  repos:
4
4
  - repo: https://github.com/pre-commit/pre-commit-hooks
5
- rev: v5.0.0
5
+ rev: v6.0.0
6
6
  hooks:
7
7
  - id: trailing-whitespace
8
8
  - id: check-added-large-files
@@ -19,7 +19,7 @@ repos:
19
19
 
20
20
  # Ruff replaces black, flake8, autoflake and isort
21
21
  - repo: https://github.com/charliermarsh/ruff-pre-commit
22
- rev: "v0.11.11" # make sure this is always consistent with hatch configs
22
+ rev: "v0.13.3" # make sure this is always consistent with hatch configs
23
23
  hooks:
24
24
  - id: ruff
25
25
  args: [--config, ./pyproject.toml]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-databases
3
- Version: 0.14.1
3
+ Version: 0.15.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
@@ -84,7 +84,7 @@ Ready-made database fixtures for your pytest tests.
84
84
 
85
85
  `pytest-databases` uses the Docker Python SDK to manage the startup and shutdown of database services in containers. The following databases are currently available:
86
86
 
87
- - **Postgres**: Version 12, 13, 14, 15, 16 and 17 are available
87
+ - **Postgres**: Version 12, 13, 14, 15, 16, 17 and 18 are available
88
88
  - **MySQL**: Version 5.6, 5.7 and 8 are available
89
89
  - **Oracle**: Version 18c XE and 23C Free are available
90
90
  - **SQL Server**: Version 2022 is available
@@ -26,7 +26,7 @@ Ready-made database fixtures for your pytest tests.
26
26
 
27
27
  `pytest-databases` uses the Docker Python SDK to manage the startup and shutdown of database services in containers. The following databases are currently available:
28
28
 
29
- - **Postgres**: Version 12, 13, 14, 15, 16 and 17 are available
29
+ - **Postgres**: Version 12, 13, 14, 15, 16, 17 and 18 are available
30
30
  - **MySQL**: Version 5.6, 5.7 and 8 are available
31
31
  - **Oracle**: Version 18c XE and 23C Free are available
32
32
  - **SQL Server**: Version 2022 is available
@@ -8,7 +8,7 @@ Installation
8
8
 
9
9
  .. code-block:: bash
10
10
 
11
- pip install pytest-databases[postgres]
11
+ pip install pytest-databases[postgres]
12
12
 
13
13
  Usage Example
14
14
  -------------
@@ -54,6 +54,7 @@ The following version-specific fixtures are also available:
54
54
  * ``postgres_15_image``, ``postgres_15_service``, ``postgres_15_connection``: PostgreSQL 15.x
55
55
  * ``postgres_16_image``, ``postgres_16_service``, ``postgres_16_connection``: PostgreSQL 16.x
56
56
  * ``postgres_17_image``, ``postgres_17_service``, ``postgres_17_connection``: PostgreSQL 17.x
57
+ * ``postgres_18_image``, ``postgres_18_service``, ``postgres_18_connection``: PostgreSQL 18.x
57
58
  * ``pgvector_image``, ``pgvector_service``. ``pgvector_connection``: Latest Available pgvector Docker image.
58
59
 
59
60
  Configuration
@@ -67,13 +68,13 @@ Example usage with custom host:
67
68
 
68
69
  .. code-block:: bash
69
70
 
70
- export POSTGRES_HOST="192.168.1.100"
71
- pytest
71
+ export POSTGRES_HOST="192.168.1.100"
72
+ pytest
72
73
 
73
74
  Service API
74
75
  -----------
75
76
 
76
77
  .. automodule:: pytest_databases.docker.postgres
77
- :members:
78
- :undoc-members:
79
- :show-inheritance:
78
+ :members:
79
+ :undoc-members:
80
+ :show-inheritance:
@@ -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.14.1"
15
+ version = "0.15.0"
16
16
  #
17
17
  authors = [{ name = "Cody Fincher", email = "cody@litestar.dev" }]
18
18
  keywords = [
@@ -122,12 +122,12 @@ dev = [
122
122
 
123
123
  [tool.bumpversion]
124
124
  allow_dirty = true
125
- commit = true
125
+ commit = false
126
126
  commit_args = "--no-verify"
127
- current_version = "0.14.0"
127
+ current_version = "0.15.0"
128
128
  ignore_missing_files = false
129
129
  ignore_missing_version = false
130
- message = "chore(release): bump to v{new_version}"
130
+ message = "chore(release): bump to `v{new_version}`"
131
131
  parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
132
132
  regex = false
133
133
  replace = "{new_version}"
@@ -135,7 +135,7 @@ search = "{current_version}"
135
135
  serialize = ["{major}.{minor}.{patch}"]
136
136
  sign_tags = false
137
137
  tag = false
138
- tag_message = "chore(release): v{new_version}"
138
+ tag_message = "chore(release): `v{new_version}`"
139
139
  tag_name = "v{new_version}"
140
140
 
141
141
  [[tool.bumpversion.files]]
@@ -139,6 +139,7 @@ class DockerService(AbstractContextManager):
139
139
  shm_size: int | None = None,
140
140
  mem_limit: str | None = None,
141
141
  platform: str | None = None,
142
+ protocol: str = "tcp",
142
143
  ) -> Generator[ServiceContainer, None, None]:
143
144
  if check is None and wait_for_log is None:
144
145
  msg = "Must set at least check or wait_for_log"
@@ -176,17 +177,32 @@ class DockerService(AbstractContextManager):
176
177
  # spins it up and the metadata becomes available, so we're redoing the
177
178
  # check with a small incremental backup here
178
179
  for i in range(10):
180
+ container.reload()
179
181
  if any(v for v in container.ports.values()):
180
182
  break
181
- container.reload()
182
183
  time.sleep(0.1 + (i / 10))
183
184
  else:
184
185
  msg = f"Service {name!r} failed to create container"
185
186
  raise ValueError(msg)
186
187
 
187
- host_port = int(
188
- container.ports[next(k for k in container.ports if k.startswith(str(container_port)))][0]["HostPort"]
189
- )
188
+ # Get port binding based on protocol configuration
189
+ binding = None
190
+ if protocol == "both":
191
+ binding = container.ports.get(f"{container_port}/tcp") or container.ports.get(f"{container_port}/udp")
192
+ elif protocol in {"tcp", "udp"}:
193
+ binding = container.ports.get(f"{container_port}/{protocol}")
194
+ else:
195
+ msg = f"Invalid protocol '{protocol}'. Must be 'tcp', 'udp', or 'both'."
196
+ raise ValueError(msg)
197
+
198
+ if not binding:
199
+ msg = (
200
+ f"Container port {container_port}/{protocol} not found in exposed ports. "
201
+ f"Available ports: {list(container.ports.keys())}"
202
+ )
203
+ raise RuntimeError(msg)
204
+
205
+ host_port = int(binding[0]["HostPort"])
190
206
  service = ServiceContainer(
191
207
  host=container_host,
192
208
  port=host_port,
@@ -244,6 +244,26 @@ def postgres_17_service(
244
244
  yield service
245
245
 
246
246
 
247
+ @pytest.fixture(autouse=False, scope="session")
248
+ def postgres_18_service(
249
+ docker_service: DockerService,
250
+ xdist_postgres_isolation_level: XdistIsolationLevel,
251
+ postgres_host: str,
252
+ postgres_user: str,
253
+ postgres_password: str,
254
+ ) -> Generator[PostgresService, None, None]:
255
+ with _provide_postgres_service(
256
+ docker_service,
257
+ image="postgres:18",
258
+ name="postgres-18",
259
+ xdist_postgres_isolate=xdist_postgres_isolation_level,
260
+ host=postgres_host,
261
+ user=postgres_user,
262
+ password=postgres_password,
263
+ ) as service:
264
+ yield service
265
+
266
+
247
267
  @pytest.fixture(autouse=False, scope="session")
248
268
  def postgres_11_connection(
249
269
  postgres_11_service: PostgresService,
@@ -356,9 +376,25 @@ def postgres_17_connection(
356
376
  yield conn
357
377
 
358
378
 
379
+ @pytest.fixture(autouse=False, scope="session")
380
+ def postgres_18_connection(
381
+ postgres_18_service: PostgresService,
382
+ ) -> Generator[psycopg.Connection, None, None]:
383
+ with psycopg.connect(
384
+ _make_connection_string(
385
+ host=postgres_18_service.host,
386
+ port=postgres_18_service.port,
387
+ user=postgres_18_service.user,
388
+ password=postgres_18_service.password,
389
+ database=postgres_18_service.database,
390
+ ),
391
+ ) as conn:
392
+ yield conn
393
+
394
+
359
395
  @pytest.fixture(autouse=False, scope="session")
360
396
  def postgres_image() -> str:
361
- return "postgres:17"
397
+ return "postgres:18"
362
398
 
363
399
 
364
400
  @pytest.fixture(autouse=False, scope="session")
@@ -13,6 +13,7 @@ import pytest
13
13
  "postgres_15_service",
14
14
  "postgres_16_service",
15
15
  "postgres_17_service",
16
+ "postgres_18_service",
16
17
  "alloydb_omni_service",
17
18
  "pgvector_service",
18
19
  ],
@@ -57,6 +58,7 @@ def test_service_fixture(pytester: pytest.Pytester, service_fixture: str) -> Non
57
58
  "postgres_15_connection",
58
59
  "postgres_16_connection",
59
60
  "postgres_17_connection",
61
+ "postgres_18_connection",
60
62
  "alloydb_omni_connection",
61
63
  "pgvector_connection",
62
64
  ],
@@ -95,8 +95,8 @@ def test_two({redis_compatible_service}: RedisService) -> None:
95
95
  assert not client.get("one")
96
96
  client.set("one", "1")
97
97
  assert client.get("one") == b"1"
98
-
99
-
98
+
99
+
100
100
  def test_use_same_db({redis_compatible_service}: RedisService) -> None:
101
101
  client_0 = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db=0)
102
102
  client_1 = redis.Redis(host={redis_compatible_service}.host, port={redis_compatible_service}.port, db=1)