pytest-databases 0.2.3__tar.gz → 0.2.4__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.
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/PKG-INFO +1 -1
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/pyproject.toml +1 -1
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/__init__.py +11 -5
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/helpers.py +19 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/.gitignore +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/.pre-commit-config.yaml +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/.sourcery.yaml +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/.vscode/settings.json +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/CODEOWNERS +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/CONTRIBUTING.rst +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/LICENSE +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/Makefile +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/README.md +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/requirements/requirements-dev.txt +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/requirements/requirements-docs.txt +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/requirements/requirements.txt +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/scripts/__init__.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/scripts/build_docs.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/scripts/convert_docs.sh +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/sonar-project.properties +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/__init__.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/__metadata__.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/cockroachdb.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/docker-compose.yml +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/dragonfly.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/keydb.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/mariadb.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/mssql.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/mysql.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/oracle.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/postgres.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/redis.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/spanner.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/py.typed +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/__init__.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/conftest.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/__init__.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_cockroachdb.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_dragonfly.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_keydb.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_mariadb.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_mssql.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_mysql.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_oracle.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_postgres.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_redis.py +0 -0
- {pytest_databases-0.2.3 → pytest_databases-0.2.4}/tests/docker/test_spanner.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pytest-databases
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
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
|
|
@@ -34,7 +34,7 @@ from typing import TYPE_CHECKING, Any, Callable
|
|
|
34
34
|
|
|
35
35
|
import pytest
|
|
36
36
|
|
|
37
|
-
from pytest_databases.helpers import wrap_sync
|
|
37
|
+
from pytest_databases.helpers import simple_string_hash, wrap_sync
|
|
38
38
|
|
|
39
39
|
if TYPE_CHECKING:
|
|
40
40
|
from collections.abc import Awaitable, Generator
|
|
@@ -70,17 +70,18 @@ SKIP_DOCKER_COMPOSE: bool = bool(os.environ.get("SKIP_DOCKER_COMPOSE", False))
|
|
|
70
70
|
USE_LEGACY_DOCKER_COMPOSE: bool = bool(
|
|
71
71
|
os.environ.get("USE_LEGACY_DOCKER_COMPOSE", os.getenv("GITHUB_ACTIONS") != "true")
|
|
72
72
|
)
|
|
73
|
+
COMPOSE_PROJECT_NAME: str = f"pytest-databases-{simple_string_hash(__file__)}"
|
|
73
74
|
|
|
74
75
|
|
|
75
76
|
class DockerServiceRegistry:
|
|
76
|
-
def __init__(self, worker_id: str) -> None:
|
|
77
|
+
def __init__(self, worker_id: str, compose_project_name: str = COMPOSE_PROJECT_NAME) -> None:
|
|
77
78
|
self._running_services: set[str] = set()
|
|
78
79
|
self.docker_ip = self._get_docker_ip()
|
|
79
80
|
self._base_command = ["docker-compose"] if USE_LEGACY_DOCKER_COMPOSE else ["docker", "compose"]
|
|
80
81
|
self._base_command.extend(
|
|
81
82
|
[
|
|
82
83
|
f"--file={Path(__file__).parent / 'docker-compose.yml'}",
|
|
83
|
-
f"--project-name=
|
|
84
|
+
f"--project-name={compose_project_name}-{worker_id}",
|
|
84
85
|
],
|
|
85
86
|
)
|
|
86
87
|
|
|
@@ -132,11 +133,16 @@ class DockerServiceRegistry:
|
|
|
132
133
|
|
|
133
134
|
|
|
134
135
|
@pytest.fixture(scope="session")
|
|
135
|
-
def
|
|
136
|
+
def compose_project_name() -> str:
|
|
137
|
+
return os.environ.get("COMPOSE_PROJECT_NAME", COMPOSE_PROJECT_NAME)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@pytest.fixture(scope="session")
|
|
141
|
+
def docker_services(compose_project_name: str, worker_id: str = "main") -> Generator[DockerServiceRegistry, None, None]:
|
|
136
142
|
if os.getenv("GITHUB_ACTIONS") == "true" and sys.platform != "linux":
|
|
137
143
|
pytest.skip("Docker not available on this platform")
|
|
138
144
|
|
|
139
|
-
registry = DockerServiceRegistry(worker_id)
|
|
145
|
+
registry = DockerServiceRegistry(worker_id, compose_project_name=compose_project_name)
|
|
140
146
|
try:
|
|
141
147
|
yield registry
|
|
142
148
|
finally:
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
|
+
import hashlib
|
|
26
27
|
import inspect
|
|
27
28
|
from contextlib import AbstractAsyncContextManager, AbstractContextManager
|
|
28
29
|
from functools import partial
|
|
@@ -81,3 +82,21 @@ def wrap_sync(fn: Callable[P, T]) -> Callable[P, Awaitable[T]]:
|
|
|
81
82
|
return await anyio.to_thread.run_sync(partial(fn, *args, **kwargs))
|
|
82
83
|
|
|
83
84
|
return wrapped
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def simple_string_hash(string_to_hash: str) -> str:
|
|
88
|
+
"""Generates a short hash based on a string.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
string_to_hash: The string to hash.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
A short hash string.
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
string_bytes = string_to_hash.encode("utf-8")
|
|
98
|
+
hasher = hashlib.sha256()
|
|
99
|
+
hasher.update(string_bytes)
|
|
100
|
+
digest = hasher.digest()
|
|
101
|
+
hex_string = digest.hex()
|
|
102
|
+
return hex_string[:12]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/cockroachdb.py
RENAMED
|
File without changes
|
{pytest_databases-0.2.3 → pytest_databases-0.2.4}/src/pytest_databases/docker/docker-compose.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|