pytest-databases 0.15.0__tar.gz → 0.16.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 (100) hide show
  1. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.github/workflows/cd.yaml +1 -1
  2. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.github/workflows/ci.yaml +9 -9
  3. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.github/workflows/docs.yml +2 -2
  4. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.github/workflows/release.yaml +2 -2
  5. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.pre-commit-config.yaml +1 -1
  6. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/PKG-INFO +9 -2
  7. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/conf.py +3 -0
  8. pytest_databases-0.16.0/docs/supported-databases/gizmosql.rst +102 -0
  9. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/index.rst +3 -0
  10. pytest_databases-0.16.0/docs/supported-databases/mongodb.rst +76 -0
  11. pytest_databases-0.16.0/docs/supported-databases/yugabyte.rst +53 -0
  12. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/pyproject.toml +44 -27
  13. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/azure_blob.py +1 -1
  14. pytest_databases-0.16.0/src/pytest_databases/docker/gizmosql.py +147 -0
  15. pytest_databases-0.16.0/src/pytest_databases/docker/mongodb.py +142 -0
  16. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/mysql.py +3 -2
  17. pytest_databases-0.16.0/src/pytest_databases/docker/yugabyte.py +96 -0
  18. pytest_databases-0.16.0/tests/conftest.py +23 -0
  19. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_azure_blob.py +3 -7
  20. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_bigquery.py +3 -3
  21. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_cockroachdb.py +4 -42
  22. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_elasticsearch.py +3 -3
  23. pytest_databases-0.16.0/tests/test_gizmosql.py +157 -0
  24. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_mariadb.py +4 -4
  25. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_minio.py +3 -7
  26. pytest_databases-0.16.0/tests/test_mongodb.py +104 -0
  27. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_mssql.py +4 -4
  28. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_mysql.py +4 -4
  29. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_oracle.py +4 -1
  30. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_postgres.py +4 -4
  31. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_redis.py +4 -8
  32. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_spanner.py +2 -2
  33. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/test_valkey.py +3 -5
  34. pytest_databases-0.16.0/tests/test_yugabyte.py +106 -0
  35. pytest_databases-0.16.0/uv.lock +5762 -0
  36. pytest_databases-0.15.0/tests/conftest.py +0 -16
  37. pytest_databases-0.15.0/uv.lock +0 -3761
  38. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.github/CODEOWNERS +0 -0
  39. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.github/dependabot.yaml +0 -0
  40. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.github/workflows/pr-title.yaml +0 -0
  41. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.gitignore +0 -0
  42. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.sourcery.yaml +0 -0
  43. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.vscode/launch.json +0 -0
  44. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/.vscode/settings.json +0 -0
  45. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/CODEOWNERS +0 -0
  46. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/CONTRIBUTING.rst +0 -0
  47. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/LICENSE +0 -0
  48. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/Makefile +0 -0
  49. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/README.md +0 -0
  50. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/.gitignore +0 -0
  51. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/__init__.py +0 -0
  52. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/_static/.gitkeep +0 -0
  53. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/_static/custom.css +0 -0
  54. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/_static/logo.svg +0 -0
  55. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/changelog.rst +0 -0
  56. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/contribution-guide.rst +0 -0
  57. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/getting-started/basic-usage.rst +0 -0
  58. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/getting-started/configuration.rst +0 -0
  59. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/getting-started/enabling-plugins.rst +0 -0
  60. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/getting-started/index.rst +0 -0
  61. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/getting-started/installation.rst +0 -0
  62. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/getting-started/next-steps.rst +0 -0
  63. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/index.rst +0 -0
  64. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/azure_blob_storage.rst +0 -0
  65. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/bigquery.rst +0 -0
  66. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/cockroachdb.rst +0 -0
  67. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/elasticsearch.rst +0 -0
  68. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/mariadb.rst +0 -0
  69. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/minio.rst +0 -0
  70. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/mysql.rst +0 -0
  71. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/oracle.rst +0 -0
  72. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/postgres.rst +0 -0
  73. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/redis.rst +0 -0
  74. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/spanner.rst +0 -0
  75. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/sqlserver.rst +0 -0
  76. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/docs/supported-databases/valkey.rst +0 -0
  77. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/scripts/__init__.py +0 -0
  78. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/scripts/build_docs.py +0 -0
  79. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/scripts/convert_docs.sh +0 -0
  80. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/scripts/install-hatch.sh +0 -0
  81. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/sonar-project.properties +0 -0
  82. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/__init__.py +0 -0
  83. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/__metadata__.py +0 -0
  84. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/_service.py +0 -0
  85. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/__init__.py +0 -0
  86. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/bigquery.py +0 -0
  87. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/cockroachdb.py +0 -0
  88. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/elastic_search.py +0 -0
  89. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/mariadb.py +0 -0
  90. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/minio.py +0 -0
  91. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/mssql.py +0 -0
  92. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/oracle.py +0 -0
  93. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/postgres.py +0 -0
  94. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/redis.py +0 -0
  95. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/spanner.py +0 -0
  96. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/docker/valkey.py +0 -0
  97. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/helpers.py +0 -0
  98. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/py.typed +0 -0
  99. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/src/pytest_databases/types.py +0 -0
  100. {pytest_databases-0.15.0 → pytest_databases-0.16.0}/tests/__init__.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@v5
16
+ uses: actions/checkout@v6
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@v5
29
+ - uses: actions/checkout@v6
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
@@ -37,10 +37,10 @@ jobs:
37
37
  python-version: ${{ matrix.python-version }}
38
38
 
39
39
  - name: Install uv
40
- uses: astral-sh/setup-uv@v6
40
+ uses: astral-sh/setup-uv@v7
41
41
 
42
42
  - name: Intall dependencies
43
- run: uv sync --frozen
43
+ run: uv sync --frozen --all-extras
44
44
 
45
45
  - if: matrix.python-version == '3.12'
46
46
  name: Run tests with coverage tracking
@@ -51,14 +51,14 @@ jobs:
51
51
  run: uv run pytest --cdist-group=${{ matrix.cdist-group }}/3 -k "not elasticsearch"
52
52
 
53
53
  - if: matrix.python-version == '3.12'
54
- uses: actions/upload-artifact@v4
54
+ uses: actions/upload-artifact@v6
55
55
  with:
56
56
  name: coverage-xml
57
57
  path: coverage.xml
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.1
61
+ uses: codecov/codecov-action@v5.5.2
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@v5
73
+ - uses: actions/checkout@v6
74
74
 
75
75
  - name: Set up Python
76
76
  uses: actions/setup-python@v6
@@ -78,10 +78,10 @@ jobs:
78
78
  python-version: 3.9
79
79
 
80
80
  - name: Install uv
81
- uses: astral-sh/setup-uv@v6
81
+ uses: astral-sh/setup-uv@v7
82
82
 
83
83
  - name: Intall dependencies
84
- run: uv sync --frozen
84
+ run: uv sync --frozen --all-extras
85
85
 
86
86
  - name: Run tests with coverage tracking
87
87
  run: uv run pytest -k elasticsearch
@@ -94,7 +94,7 @@ jobs:
94
94
  # runs-on: ubuntu-latest
95
95
  # steps:
96
96
  # - name: Check out repository
97
- # uses: actions/checkout@v5
97
+ # uses: actions/checkout@v6
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@v5
23
+ - uses: actions/checkout@v6
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
@@ -31,7 +31,7 @@ jobs:
31
31
  python-version: 3.12
32
32
 
33
33
  - name: Install uv
34
- uses: astral-sh/setup-uv@v6
34
+ uses: astral-sh/setup-uv@v7
35
35
 
36
36
  - name: Set up Python
37
37
  run: uv python install 3.12
@@ -16,10 +16,10 @@ 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@v5
19
+ uses: actions/checkout@v6
20
20
 
21
21
  - name: Install uv
22
- uses: astral-sh/setup-uv@v6
22
+ uses: astral-sh/setup-uv@v7
23
23
 
24
24
  - name: Set up Python
25
25
  run: uv python install 3.12
@@ -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.13.3" # make sure this is always consistent with hatch configs
22
+ rev: "v0.14.13" # 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.15.0
3
+ Version: 0.16.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@litestar.dev>
9
9
  License-Expression: MIT
10
10
  License-File: LICENSE
11
- Keywords: alloydb,alloydbomni,azure,bigquery,cockroachdb,database,dragonflydb,duckdb,elasticsearch,migration,mssql,mysql,oracle,postgres,redis,spanner,valkey
11
+ Keywords: alloydb,alloydbomni,azure,bigquery,cockroachdb,database,dragonflydb,duckdb,elasticsearch,flightsql,gizmosql,migration,mongodb,mssql,mysql,oracle,postgres,redis,spanner,valkey
12
12
  Classifier: Development Status :: 4 - Beta
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3.9
@@ -34,12 +34,17 @@ Provides-Extra: elasticsearch7
34
34
  Requires-Dist: elasticsearch7; extra == 'elasticsearch7'
35
35
  Provides-Extra: elasticsearch8
36
36
  Requires-Dist: elasticsearch8; extra == 'elasticsearch8'
37
+ Provides-Extra: gizmosql
38
+ Requires-Dist: adbc-driver-flightsql; extra == 'gizmosql'
39
+ Requires-Dist: pyarrow; extra == 'gizmosql'
37
40
  Provides-Extra: keydb
38
41
  Requires-Dist: redis; extra == 'keydb'
39
42
  Provides-Extra: mariadb
40
43
  Requires-Dist: mariadb; extra == 'mariadb'
41
44
  Provides-Extra: minio
42
45
  Requires-Dist: minio; extra == 'minio'
46
+ Provides-Extra: mongodb
47
+ Requires-Dist: pymongo; extra == 'mongodb'
43
48
  Provides-Extra: mssql
44
49
  Requires-Dist: pymssql; extra == 'mssql'
45
50
  Provides-Extra: mysql
@@ -54,6 +59,8 @@ Provides-Extra: spanner
54
59
  Requires-Dist: google-cloud-spanner; extra == 'spanner'
55
60
  Provides-Extra: valkey
56
61
  Requires-Dist: valkey; extra == 'valkey'
62
+ Provides-Extra: yugabyte
63
+ Requires-Dist: psycopg2-yugabytedb; extra == 'yugabyte'
57
64
  Description-Content-Type: text/markdown
58
65
 
59
66
  <!-- markdownlint-disable no-inline-html -->
@@ -63,6 +63,9 @@ autodoc_default_options = {
63
63
  "exclude-members": "__weakref__",
64
64
  }
65
65
 
66
+ # Mock imports for modules not needed during doc generation
67
+ autodoc_mock_imports = ["OpenSSL"]
68
+
66
69
  # Intersphinx settings
67
70
  intersphinx_mapping = {
68
71
  "python": ("https://docs.python.org/3", None),
@@ -0,0 +1,102 @@
1
+ GizmoSQL
2
+ ========
3
+
4
+ Integration with `GizmoSQL <https://github.com/gizmodata/gizmosql>`_, a high-performance SQL server built on Apache Arrow Flight SQL with DuckDB/SQLite backends.
5
+
6
+ .. note::
7
+
8
+ GizmoSQL always runs with TLS enabled using auto-generated self-signed certificates.
9
+ The connection fixtures automatically skip certificate verification for testing purposes.
10
+
11
+ Installation
12
+ ------------
13
+
14
+ .. code-block:: bash
15
+
16
+ pip install pytest-databases[gizmosql]
17
+
18
+ Usage Example
19
+ -------------
20
+
21
+ Using the service fixture:
22
+
23
+ .. code-block:: python
24
+
25
+ import pytest
26
+ from adbc_driver_flightsql import dbapi as flightsql
27
+ from pytest_databases.docker.gizmosql import GizmoSQLService, _make_connection_kwargs
28
+
29
+ pytest_plugins = ["pytest_databases.docker.gizmosql"]
30
+
31
+ def test(gizmosql_service: GizmoSQLService) -> None:
32
+ db_kwargs = _make_connection_kwargs(
33
+ gizmosql_service.username,
34
+ gizmosql_service.password,
35
+ )
36
+ with flightsql.connect(
37
+ uri=gizmosql_service.uri,
38
+ db_kwargs=db_kwargs,
39
+ autocommit=True,
40
+ ) as conn:
41
+ with conn.cursor() as cur:
42
+ cur.execute("SELECT 1")
43
+ result = cur.fetchone()
44
+ assert result is not None and result[0] == 1
45
+
46
+ Using the connection fixture:
47
+
48
+ .. code-block:: python
49
+
50
+ import pytest
51
+
52
+ pytest_plugins = ["pytest_databases.docker.gizmosql"]
53
+
54
+ def test(gizmosql_connection) -> None:
55
+ with gizmosql_connection.cursor() as cur:
56
+ cur.execute("""
57
+ CREATE TABLE test_table (id INTEGER, name VARCHAR);
58
+ INSERT INTO test_table VALUES (1, 'test');
59
+ """)
60
+
61
+ with gizmosql_connection.cursor() as cur:
62
+ cur.execute("SELECT * FROM test_table")
63
+ result = cur.fetchone()
64
+ assert result is not None
65
+ assert result[0] == 1
66
+
67
+ .. note::
68
+
69
+ Due to Flight SQL semantics, DDL and DML statements should be combined in a single
70
+ ``execute()`` call for immediate visibility across cursor operations.
71
+
72
+ Available Fixtures
73
+ ------------------
74
+
75
+ * ``gizmosql_image``: The Docker image to use for GizmoSQL (default: ``gizmodata/gizmosql:latest``).
76
+ * ``gizmosql_username``: The username for authentication.
77
+ * ``gizmosql_password``: The password for authentication.
78
+ * ``gizmosql_service``: A fixture that provides a GizmoSQL service container.
79
+ * ``gizmosql_connection``: A fixture that provides an ADBC Flight SQL connection.
80
+ * ``xdist_gizmosql_isolation_level``: Xdist isolation level (default: ``server``).
81
+
82
+ Parallel Testing (xdist)
83
+ ------------------------
84
+
85
+ GizmoSQL only supports ``server`` isolation level for pytest-xdist parallel testing.
86
+ This means each xdist worker gets its own dedicated container. Database-level isolation
87
+ is not supported because DuckDB (the default backend) doesn't support multiple databases
88
+ per instance.
89
+
90
+ .. code-block:: python
91
+
92
+ @pytest.fixture(scope="session")
93
+ def xdist_gizmosql_isolation_level():
94
+ return "server" # This is the only supported value
95
+
96
+ Service API
97
+ -----------
98
+
99
+ .. automodule:: pytest_databases.docker.gizmosql
100
+ :members:
101
+ :undoc-members:
102
+ :show-inheritance:
@@ -14,6 +14,9 @@ This section provides detailed information on the supported databases, including
14
14
  spanner
15
15
  bigquery
16
16
  cockroachdb
17
+ yugabyte
18
+ mongodb
19
+ gizmosql
17
20
  redis
18
21
  valkey
19
22
  elasticsearch
@@ -0,0 +1,76 @@
1
+ MongoDB
2
+ =======
3
+
4
+ Integration with `MongoDB <https://www.mongodb.com/>`_, a NoSQL document-oriented database.
5
+
6
+ This integration uses the official `PyMongo <https://pymongo.readthedocs.io/>`_ driver to interact with MongoDB.
7
+
8
+ Installation
9
+ ------------
10
+
11
+ .. code-block:: bash
12
+
13
+ pip install pytest-databases[mongodb]
14
+
15
+
16
+ Usage Example
17
+ -------------
18
+
19
+ .. code-block:: python
20
+
21
+ import pytest
22
+ import pymongo
23
+ from pytest_databases.docker.mongodb import MongoDBService
24
+
25
+ pytest_plugins = ["pytest_databases.docker.mongodb"]
26
+
27
+ def test_mongodb_service(mongodb_service: MongoDBService) -> None:
28
+ client = pymongo.MongoClient(
29
+ host=mongodb_service.host,
30
+ port=mongodb_service.port,
31
+ username=mongodb_service.username,
32
+ password=mongodb_service.password,
33
+ )
34
+ # Ping the server to ensure connection
35
+ client.admin.command("ping")
36
+ client.close()
37
+
38
+ def test_mongodb_connection(mongodb_connection: pymongo.MongoClient) -> None:
39
+ # mongodb_connection is an instance of pymongo.MongoClient
40
+ # You can use it to interact with the database
41
+ db = mongodb_connection["mydatabase"]
42
+ collection = db["mycollection"]
43
+ collection.insert_one({"name": "test_document", "value": 1})
44
+ result = collection.find_one({"name": "test_document"})
45
+ assert result is not None
46
+ assert result["value"] == 1
47
+ # Clean up (optional, depending on your test needs)
48
+ collection.delete_one({"name": "test_document"})
49
+ mongodb_connection.close()
50
+
51
+ def test_mongodb_database(mongodb_database: pymongo.database.Database) -> None:
52
+ # mongodb_database is an instance of pymongo.database.Database
53
+ # This fixture provides a database that is unique per test function if xdist is used
54
+ # and xdist_mongodb_isolation_level is "database" (the default).
55
+ collection = mongodb_database["mycollection"]
56
+ collection.insert_one({"name": "another_document", "value": 2})
57
+ result = collection.find_one({"name": "another_document"})
58
+ assert result is not None
59
+ assert result["value"] == 2
60
+ # No need to close the database object explicitly, the connection is managed by mongodb_connection
61
+
62
+ Available Fixtures
63
+ ------------------
64
+
65
+ * ``mongodb_service``: A fixture that provides a MongoDB service, giving access to connection details like host, port, username, and password.
66
+ * ``mongodb_connection``: A fixture that provides a ``pymongo.MongoClient`` instance connected to the MongoDB service.
67
+ * ``mongodb_database``: A fixture that provides a ``pymongo.database.Database`` instance.
68
+ * ``mongodb_image``: A fixture that returns the Docker image name used for the MongoDB service (default: "mongo:latest"). You can override this fixture to use a different MongoDB version.
69
+
70
+ Service API
71
+ -----------
72
+
73
+ .. automodule:: pytest_databases.docker.mongodb
74
+ :members: MongoDBService, _provide_mongodb_service
75
+ :undoc-members:
76
+ :show-inheritance:
@@ -0,0 +1,53 @@
1
+ Yugabyte
2
+ ========
3
+
4
+ Integration with `Yugabyte DB <https://www.yugabyte.com/>`_
5
+
6
+ Installation
7
+ ------------
8
+
9
+ .. code-block:: bash
10
+
11
+ pip install pytest-databases[yugabyte]
12
+
13
+ Usage Example
14
+ -------------
15
+
16
+ .. code-block:: python
17
+
18
+ import pytest
19
+ import psycopg
20
+ from pytest_databases.docker.yugabyte import YugabyteService
21
+
22
+ pytest_plugins = ["pytest_databases.docker.yugabyte"]
23
+
24
+ @pytest.fixture(scope="session")
25
+ def yugabyte_uri(yugabyte_service: YugabyteService) -> str:
26
+ opts = "&".join(f"{k}={v}" for k, v in yugabyte_service.driver_opts.items())
27
+ return f"postgresql://yugabyte:yugabyte@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?{opts}"
28
+
29
+ def test_yugabyte_service(yugabyte_uri: str) -> None:
30
+ with psycopg.connect(yugabyte_uri) as conn:
31
+ db_open = conn.execute("SELECT 1").fetchone()
32
+ assert db_open is not None and db_open[0] == 1
33
+
34
+ def test_yugabyte_connection(yugabyte_connection: psycopg.Connection) -> None:
35
+ yugabyte_connection.execute("CREATE TABLE if not exists simple_table as SELECT 1")
36
+ result = yugabyte_connection.execute("select * from simple_table").fetchone()
37
+ assert result is not None and result[0] == 1
38
+
39
+ Available Fixtures
40
+ ------------------
41
+
42
+ * ``yugabyte_image``: The Docker image to use for Yugabyte DB.
43
+ * ``yugabyte_service``: A fixture that provides a Yugabyte DB service.
44
+ * ``yugabyte_connection``: A fixture that provides a Yugabyte DB connection.
45
+ * ``yugabyte_driver_opts``: A fixture that provides driver options for Yugabyte DB.
46
+
47
+ Service API
48
+ -----------
49
+
50
+ .. automodule:: pytest_databases.docker.yugabyte
51
+ :members:
52
+ :undoc-members:
53
+ :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.15.0"
15
+ version = "0.16.0"
16
16
  #
17
17
  authors = [{ name = "Cody Fincher", email = "cody@litestar.dev" }]
18
18
  keywords = [
@@ -33,6 +33,9 @@ keywords = [
33
33
  "azure",
34
34
  "valkey",
35
35
  "dragonflydb",
36
+ "mongodb",
37
+ "gizmosql",
38
+ "flightsql",
36
39
  ]
37
40
  # options under https://pypi.org/classifiers/
38
41
  classifiers = [
@@ -61,9 +64,11 @@ cockroachdb = ["psycopg"]
61
64
  dragonfly = ["redis"]
62
65
  elasticsearch7 = ["elasticsearch7"]
63
66
  elasticsearch8 = ["elasticsearch8"]
67
+ gizmosql = ["adbc-driver-flightsql", "pyarrow"]
64
68
  keydb = ["redis"]
65
69
  mariadb = ["mariadb"]
66
70
  minio = ["minio"]
71
+ mongodb = ["pymongo"]
67
72
  mssql = ["pymssql"]
68
73
  mysql = ["mysql-connector-python"]
69
74
  oracle = ["oracledb"]
@@ -71,34 +76,18 @@ postgres = ["psycopg>=3"]
71
76
  redis = ["redis"]
72
77
  spanner = ["google-cloud-spanner"]
73
78
  valkey = ["valkey"]
79
+ yugabyte = ["psycopg2-yugabytedb"]
74
80
 
75
81
  [dependency-groups]
82
+ build = ["bump-my-version"]
76
83
  dev = [
77
- # tests
78
- "bump-my-version",
79
- "pytest-databases[azure-storage,bigquery,cockroachdb,dragonfly,elasticsearch7,elasticsearch8,keydb,mssql,mysql,mariadb,oracle,postgres,redis,spanner,minio,valkey]",
80
- "coverage[toml]>=6.2",
81
- "pytest",
82
- "pytest-cov",
83
- "pytest-cdist>=0.2",
84
- "pytest-mock",
85
- "pytest-click",
86
- "pytest-xdist",
87
- "slotscheck",
88
- "psycopg-binary", # This fixes tests failing on M series CPUs.
89
- # lint
90
- "mypy",
91
- "ruff",
92
- "pyright",
93
- "pre-commit",
94
- "types-click",
95
- "types-six",
96
- "types-decorator",
97
- "types-pyyaml",
98
- "types-docutils",
99
- "types-redis",
100
- "types-pymysql",
101
- # docs
84
+ { include-group = "extra" },
85
+ { include-group = "lint" },
86
+ { include-group = "doc" },
87
+ { include-group = "test" },
88
+ { include-group = "build" },
89
+ ]
90
+ doc = [
102
91
  "auto-pytabs[sphinx]>=0.5.0",
103
92
  "shibuya",
104
93
  "sphinx>=7.0.0; python_version <= \"3.9\"",
@@ -115,6 +104,31 @@ dev = [
115
104
  "sphinx-autodoc-typehints",
116
105
  "sphinx-rtd-theme",
117
106
  ]
107
+ extra = ["psycopg2-binary", "psycopg[binary,pool]", "psycopg2-yugabytedb-binary"]
108
+ lint = [
109
+ "mypy",
110
+ "ruff",
111
+ "pyright",
112
+ "pre-commit",
113
+ "types-click",
114
+ "types-six",
115
+ "types-decorator",
116
+ "types-pyyaml",
117
+ "types-docutils",
118
+ "types-redis",
119
+ "types-pymysql",
120
+ "slotscheck",
121
+ ]
122
+ test = [
123
+ "coverage[toml]>=6.2",
124
+ "pytest",
125
+ "pytest-cov",
126
+ "pytest-cdist>=0.2",
127
+ "pytest-mock",
128
+ "pytest-click",
129
+ "pytest-xdist",
130
+ "pytest-sugar",
131
+ ]
118
132
 
119
133
  ##################
120
134
  # External Tools #
@@ -124,7 +138,7 @@ dev = [
124
138
  allow_dirty = true
125
139
  commit = false
126
140
  commit_args = "--no-verify"
127
- current_version = "0.15.0"
141
+ current_version = "0.16.0"
128
142
  ignore_missing_files = false
129
143
  ignore_missing_version = false
130
144
  message = "chore(release): bump to `v{new_version}`"
@@ -297,6 +311,8 @@ lint.ignore = [
297
311
  "DOC502", # Raised exception missing from docstring
298
312
  "A005", # module shadows builtin
299
313
  "S608",
314
+ "RUF067", # __init__ module should only contain docstrings and re-exports
315
+ "B901", # Using `yield` and `return {value}` in a generator function can lead to confusing behavior
300
316
  ]
301
317
  lint.select = ["ALL"]
302
318
  # Allow unused variables when underscore-prefixed.
@@ -384,6 +400,7 @@ markers = [
384
400
  "duckdb: DuckDB Tests",
385
401
  "mssql: Microsoft SQL Server Tests",
386
402
  "elasticsearch: Elasticsearch Tests",
403
+ "gizmosql: GizmoSQL Tests",
387
404
  ]
388
405
  testpaths = ["tests"]
389
406
 
@@ -48,7 +48,7 @@ def azure_blob_service(
48
48
  azurite_in_memory: bool,
49
49
  azure_blob_xdist_isolation_level: XdistIsolationLevel,
50
50
  ) -> Generator[ServiceContainer, None, None]:
51
- command = "azurite-blob --blobHost 0.0.0.0 --blobPort 10000"
51
+ command = "azurite-blob --blobHost 0.0.0.0 --blobPort 10000 --skipApiVersionCheck"
52
52
  if azurite_in_memory:
53
53
  command += " --inMemoryPersistence"
54
54