Skip to content

Commit 18875e1

Browse files
authored
feat: move MariaDB to clientless validation (#126)
## Summary - remove pytest-databases runtime/test dependency on the MariaDB Python client - keep `pytest-databases[mariadb]` as an empty compatibility extra - validate MariaDB availability and tests with the container-bundled `mariadb` CLI - update MariaDB docs to describe user-owned clients and service-only fixtures This also includes the previously stacked PRs for #127 #128
1 parent 066ebc1 commit 18875e1

14 files changed

Lines changed: 602 additions & 717 deletions

File tree

docs/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"undoc-members": True,
6363
"exclude-members": "__weakref__",
6464
}
65+
autodoc_type_aliases = {
66+
"Container": "docker.models.containers.Container",
67+
}
6568

6669
# Mock imports for modules not needed during doc generation
6770
autodoc_mock_imports = ["OpenSSL"]

docs/supported-databases/mariadb.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Integration with `MariaDB <https://mariadb.org>`_, a community-developed, commer
66
Installation
77
------------
88

9-
MariaDB support is built-in and does not require any additional Python client libraries for basic service management. However, to connect to the database from your tests, you should install your preferred MariaDB client (e.g., `mariadb`).
9+
The fixture provides a running MariaDB service and validates availability with the container's bundled tools. Use the
10+
service attributes with the MariaDB client, ORM, or application configuration you normally use.
1011

1112
Usage Example
1213
-------------
@@ -20,7 +21,6 @@ Usage Example
2021
pytest_plugins = ["pytest_databases.docker.mariadb"]
2122
2223
def test(mariadb_service: MariaDBService) -> None:
23-
# Create your own connection using the service fixture attributes
2424
with mariadb.connect(
2525
host=mariadb_service.host,
2626
port=mariadb_service.port,
@@ -36,16 +36,17 @@ Available Fixtures
3636
------------------
3737

3838
* ``mariadb_service``: A fixture that provides a MariaDB service (11.4 LTS).
39+
* ``mariadb_user``: The application user configured in the container.
40+
* ``mariadb_password``: The application user password configured in the container.
41+
* ``mariadb_root_password``: The root password configured in the container.
42+
* ``mariadb_database``: The initial database configured in the container.
3943

4044
The following version-specific fixtures are also available:
4145

4246
* ``mariadb_113_service``: MariaDB 11.3
4347
* ``mariadb_114_service``: MariaDB 11.4 LTS
4448
* ``mariadb_122_service``: MariaDB 12.2 Rolling
4549

46-
.. note::
47-
The connection fixtures (e.g., ``mariadb_connection``, ``mariadb_114_connection``) are deprecated and will be removed in a future release. Users are encouraged to create their own connections as shown in the example above.
48-
4950
Service API
5051
-----------
5152

docs/supported-databases/mysql.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Integration with `MySQL <https://www.mysql.com/>`_
66
Installation
77
------------
88

9-
MySQL support is built-in and does not require any additional Python client libraries for basic service management. However, to connect to the database from your tests, you should install your preferred MySQL client (e.g., `mysql-connector-python`).
9+
The fixture provides a running MySQL service and validates availability with the container's bundled tools. Use the
10+
service attributes with the MySQL client, ORM, or application configuration you normally use.
1011

1112
Usage Example
1213
-------------
@@ -20,7 +21,6 @@ Usage Example
2021
pytest_plugins = ["pytest_databases.docker.mysql"]
2122
2223
def test(mysql_service: MySQLService) -> None:
23-
# Create your own connection using the service fixture attributes
2424
with mysql.connector.connect(
2525
host=mysql_service.host,
2626
port=mysql_service.port,
@@ -36,6 +36,10 @@ Available Fixtures
3636
------------------
3737

3838
* ``mysql_service``: A fixture that provides a MySQL service (8.4 LTS).
39+
* ``mysql_user``: The application user configured in the container.
40+
* ``mysql_password``: The application user password configured in the container.
41+
* ``mysql_root_password``: The root password configured in the container.
42+
* ``mysql_database``: The initial database configured in the container.
3943

4044
The following version-specific fixtures are also available:
4145

@@ -45,9 +49,6 @@ The following version-specific fixtures are also available:
4549
* ``mysql_84_service``: MySQL 8.4 LTS
4650
* ``mysql_96_service``: MySQL 9.6 Innovation
4751

48-
.. note::
49-
The connection fixtures (e.g., ``mysql_connection``, ``mysql_84_connection``) are deprecated and will be removed in a future release. Users are encouraged to create their own connections as shown in the example above.
50-
5152
Service API
5253
-----------
5354

docs/supported-databases/yugabyte.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Installation
1010
1111
pip install pytest-databases[yugabyte]
1212
13+
The fixture provides a running Yugabyte service and validates availability with Yugabyte's bundled tools. Use the
14+
service attributes with the PostgreSQL-compatible client, ORM, or application configuration you normally use.
15+
1316
Usage Example
1417
-------------
1518

@@ -23,26 +26,24 @@ Usage Example
2326
2427
@pytest.fixture(scope="session")
2528
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}"
29+
return (
30+
f"postgresql://{yugabyte_service.user}:{yugabyte_service.password}"
31+
f"@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?sslmode=disable"
32+
)
2833
2934
def test_yugabyte_service(yugabyte_uri: str) -> None:
3035
with psycopg.connect(yugabyte_uri) as conn:
3136
db_open = conn.execute("SELECT 1").fetchone()
3237
assert db_open is not None and db_open[0] == 1
3338
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-
3939
Available Fixtures
4040
------------------
4141

4242
* ``yugabyte_image``: The Docker image to use for Yugabyte DB.
43+
* ``yugabyte_user``: The Yugabyte user exposed on ``yugabyte_service``.
44+
* ``yugabyte_password``: The Yugabyte password exposed on ``yugabyte_service``.
45+
* ``yugabyte_database``: The database created for ``yugabyte_service``.
4346
* ``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.
4647

4748
Service API
4849
-----------

pyproject.toml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,16 @@ elasticsearch7 = ["elasticsearch7"]
6767
elasticsearch8 = ["elasticsearch8"]
6868
gizmosql = ["adbc-driver-flightsql", "pyarrow"]
6969
keydb = ["redis"]
70+
mariadb = []
7071
mongodb = ["pymongo"]
7172
mssql = ["pymssql"]
73+
mysql = []
7274
oracle = ["oracledb"]
7375
postgres = ["psycopg>=3"]
7476
redis = ["redis"]
7577
spanner = ["google-cloud-spanner"]
7678
valkey = ["valkey"]
77-
yugabyte = ["psycopg2-yugabytedb"]
79+
yugabyte = []
7880

7981
[dependency-groups]
8082
build = ["bump-my-version"]
@@ -102,7 +104,7 @@ doc = [
102104
"sphinx-autodoc-typehints",
103105
"sphinx-rtd-theme",
104106
]
105-
extra = ["psycopg2-binary", "psycopg[binary,pool]", "psycopg2-yugabytedb-binary"]
107+
extra = ["psycopg[binary,pool]"]
106108
lint = [
107109
"mypy",
108110
"ruff",
@@ -126,15 +128,6 @@ test = [
126128
"pytest-click",
127129
"pytest-xdist",
128130
"pytest-sugar",
129-
# mysql-connector-python's wheel coverage degrades unpredictably each release:
130-
# 3.9: 9.4.x is the last release with cp39 wheels
131-
# 3.10+: 9.6.x is the latest release with full Linux/macOS/Windows coverage
132-
# (9.7.0 dropped Linux/Windows for cp311 and dropped cp312/cp313 entirely)
133-
# Lower bounds force uv to fork the resolution per-interpreter - without them
134-
# a single 9.4.0 satisfies every marker and gets locked universally.
135-
"mysql-connector-python<9.5; python_version < '3.10'",
136-
"mysql-connector-python>=9.6,<9.7; python_version >= '3.10'",
137-
"mariadb",
138131
]
139132

140133
##################

0 commit comments

Comments
 (0)