Yugabyte

Integration with Yugabyte DB

Installation

pip install pytest-databases[yugabyte]

The fixture provides a running Yugabyte service and validates availability with Yugabyte’s bundled tools. Use the service attributes with the PostgreSQL-compatible client, ORM, or application configuration you normally use.

Usage Example

import pytest
import psycopg
from pytest_databases.docker.yugabyte import YugabyteService

pytest_plugins = ["pytest_databases.docker.yugabyte"]

@pytest.fixture(scope="session")
def yugabyte_uri(yugabyte_service: YugabyteService) -> str:
    return (
        f"postgresql://{yugabyte_service.user}:{yugabyte_service.password}"
        f"@{yugabyte_service.host}:{yugabyte_service.port}/{yugabyte_service.database}?sslmode=disable"
    )

def test_yugabyte_service(yugabyte_uri: str) -> None:
    with psycopg.connect(yugabyte_uri) as conn:
        db_open = conn.execute("SELECT 1").fetchone()
        assert db_open is not None and db_open[0] == 1

Available Fixtures

  • yugabyte_image: The Docker image to use for Yugabyte DB.

  • yugabyte_user: The Yugabyte user exposed on yugabyte_service.

  • yugabyte_password: The Yugabyte password exposed on yugabyte_service.

  • yugabyte_database: The database created for yugabyte_service.

  • yugabyte_service: A fixture that provides a Yugabyte DB service.

Service API

pytest_databases.docker.yugabyte.xdist_yugabyte_isolation_level()[source]
Return type:

Literal['database', 'server']

class pytest_databases.docker.yugabyte.YugabyteService(container, host, port, database, user, password)[source]

Bases: ServiceContainer

database: str
user: str
password: str
__init__(container, host, port, database, user, password)
pytest_databases.docker.yugabyte.yugabyte_image()[source]
Return type:

str

pytest_databases.docker.yugabyte.yugabyte_user()[source]
Return type:

str

pytest_databases.docker.yugabyte.yugabyte_password()[source]
Return type:

str

pytest_databases.docker.yugabyte.yugabyte_database()[source]
Return type:

str

pytest_databases.docker.yugabyte.yugabyte_service(docker_service, xdist_yugabyte_isolation_level, yugabyte_image, yugabyte_user, yugabyte_password, yugabyte_database)[source]
Return type:

Generator[YugabyteService, None, None]