Oracle

Integration with Oracle Database

Installation

pip install pytest-databases[oracle]

Usage Example

import oracledb
from pytest_databases.docker.oracle import OracleService

pytest_plugins = ["pytest_databases.docker.oracle"]

def test(oracle_service: OracleService) -> None:
    # ``oracledb`` is user-owned application code; pytest-databases only
    # starts the service and provides connection metadata.
    conn = oracledb.connect(
        user=oracle_service.user,
        password=oracle_service.password,
        service_name=oracle_service.service_name,
        host=oracle_service.host,
        port=oracle_service.port,
    )
    with conn.cursor() as cur:
        cur.execute("SELECT 1 FROM dual")
        res = cur.fetchone()[0]
        assert res == 1

Available Fixtures

  • oracle_user: The application username created in the Oracle container.

  • oracle_password: The application user password.

  • oracle_system_password: The Oracle system password.

  • oracle_service: Alias for the latest supported Oracle service.

The following version-specific fixtures are also available:

  • oracle_18c_image, oracle_18c_service_name, oracle_18c_service: Oracle 18c

  • oracle_23ai_image, oracle_23ai_service_name, oracle_23ai_service: Oracle 23ai

Service API

class pytest_databases.docker.oracle.OracleService(container, host, port, user, password, system_password, service_name)[source]

Bases: ServiceContainer

user: str
password: str
system_password: str
service_name: str
__init__(container, host, port, user, password, system_password, service_name)
pytest_databases.docker.oracle.oracle_23ai_image()[source]
Return type:

str

pytest_databases.docker.oracle.oracle_23ai_service_name()[source]
Return type:

str

pytest_databases.docker.oracle.oracle_18c_image()[source]
Return type:

str

pytest_databases.docker.oracle.oracle_18c_service_name()[source]
Return type:

str

pytest_databases.docker.oracle.oracle_user()[source]
Return type:

str

pytest_databases.docker.oracle.oracle_password()[source]
Return type:

str

pytest_databases.docker.oracle.oracle_system_password()[source]
Return type:

str

pytest_databases.docker.oracle.oracle_23ai_service(docker_service, oracle_23ai_image, oracle_23ai_service_name, oracle_user, oracle_password, oracle_system_password)[source]
Return type:

Generator[OracleService, None, None]

pytest_databases.docker.oracle.oracle_18c_service(docker_service, oracle_18c_image, oracle_18c_service_name, oracle_user, oracle_password, oracle_system_password)[source]
Return type:

Generator[OracleService, None, None]

pytest_databases.docker.oracle.oracle_service(oracle_23ai_service)[source]
Return type:

OracleService