Skip to main content

RavenDB Test Driver

ravendb-test-driver runs integration tests against a real RavenDB server instead of a mock. It creates an isolated database for each test and deletes that database when its DocumentStore is closed. Your tests use the standard ravendb client API.

Install

pip install ravendb-test-driver

Python 3.10+ is required.

Quick start

With the default configuration, the driver starts an embedded RavenDB server and gives every store its own database:

from ravendb_test_driver import RavenTestDriver

with RavenTestDriver() as driver:
    with driver.get_document_store() as store:
        with store.open_session() as session:
            session.store({"name": "John"}, "people/1")
            session.save_changes()

        with store.open_session() as session:
            assert session.load("people/1", dict)["name"] == "John"

The default mode requires a matching system .NET runtime. The two alternatives below do not require .NET on the machine running the Python tests.

Choose where RavenDB runs

Mode .NET on the test machine? Who manages the server? Best for
Embedded default Yes Test driver The simplest local setup
On-demand self-contained No Test driver Portable developer machines and CI runners
Attach to your server No You Docker, Testcontainers, or a shared service

Configure the selected mode before the first call to get_document_store().

Embedded server (default)

No configuration is needed. The driver starts the framework-dependent server bundled with ravendb-embedded.

ravendb-test-driver version Required runtime
7.2.x .NET 10
7.1.x .NET 8

Run dotnet --list-runtimes and look for Microsoft.NETCore.App. Re-check the requirement when upgrading to a new RavenDB minor version.

Runnable walkthrough: Lab 02 — isolated embedded databases.

On-demand self-contained server

Let the driver download, cache, and manage the self-contained build for the current platform:

from ravendb_embedded import ServerOptions
from ravendb_test_driver import RavenTestDriver

options = ServerOptions()
options.with_auto_downloaded_server()
RavenTestDriver.configure_server(options)

with RavenTestDriver() as driver:
    with driver.get_document_store() as store:
        ...

The same test configuration works across supported Windows, Linux, and macOS machines because the operating system and architecture are detected at runtime. The first run downloads 100 MB+; later runs reuse ~/.cache/ravendb-embedded. Pass cache_root to with_auto_downloaded_server() when your build system restores a different cache directory.

Supported targets are Windows x64/x86, Linux x64/ARM64, and macOS x64/ARM64. Self-contained mode removes the system .NET requirement, but normal RavenDB operating-system dependencies still apply. Minimal Linux images may need their distribution's ICU package. The Python wheel stays platform-independent because it downloads only the self-contained build needed by the current machine rather than bundling every platform.

Runnable walkthrough: Lab 04 — portable embedded tests without .NET.

Attach to a server you run

Start RavenDB yourself—locally, in Docker or Testcontainers, or as a shared service—and configure its URL:

from ravendb_test_driver import RavenTestDriver

RavenTestDriver.configure_external_server("http://localhost:8080")

Alternatively, configure the URL through the environment:

RAVENDB_TEST_SERVER_URL=http://localhost:8080 python -m unittest

This path does not use EmbeddedServer: the driver neither starts nor stops the server, but it still creates and deletes an isolated database for each test. No .NET installation is needed on the test machine; the server environment supplies its own runtime.

For HTTPS with client-certificate authentication:

RavenTestDriver.configure_external_server(
    "https://my-ravendb",
    certificate_pem_path="client.pem",
    trust_store_path="ca.crt",
)

The equivalent environment variables are:

  • RAVENDB_TEST_SERVER_URL
  • RAVENDB_TEST_SERVER_CERT
  • RAVENDB_TEST_SERVER_CA

trust_store_path or RAVENDB_TEST_SERVER_CA is needed when the server's CA is not already trusted by the test machine.

Runnable walkthrough: Lab 01 — Docker, Testcontainers, and shared servers.

Test lifecycle

Create a RavenTestDriver for the test or fixture, then close every returned store. A context manager handles both steps:

from unittest import TestCase
from ravendb_test_driver import RavenTestDriver


class TestPeople(TestCase):
    def test_stores_a_person(self):
        with RavenTestDriver() as driver:
            with driver.get_document_store() as store:
                with store.open_session() as session:
                    session.store({"name": "John"}, "people/1")
                    session.save_changes()

Each get_document_store() call creates a new database. Closing the store deletes it, which keeps tests independent even when they share one RavenDB server process.

Seed data and wait for indexing

Override setup_database(self, store) to create indexes or seed reference data whenever the driver creates a database:

class PeopleTestDriver(RavenTestDriver):
    def setup_database(self, store):
        with store.open_session() as session:
            session.store({"name": "Seeded"}, "people/seed")
            session.save_changes()

Use GetDocumentStoreOptions.wait_for_indexing_timeout when a store should not be returned until indexing settles, or call wait_for_indexing(store) directly.

wait_for_user_to_continue_the_test(store) opens RavenDB Studio and pauses the test for manual inspection.

Runnable walkthrough: Lab 03 — seeding and indexes.

Labs

Lab Scenario Needs system .NET?
01 Attach to Docker, Testcontainers, or a shared server No
02 Default embedded server and isolated databases Yes
03 Seed data and wait for real indexing Yes
04 On-demand self-contained server No

The runnable scripts live in this repository rather than site-packages. Clone or download the repository, install the package, and run them from the repository root. See the complete labs guide.

For lower-level server configuration, see ravendb-embedded.

Links

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ravendb_test_driver-7.2.5.post2.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ravendb_test_driver-7.2.5.post2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file ravendb_test_driver-7.2.5.post2.tar.gz.

File metadata

File hashes

Hashes for ravendb_test_driver-7.2.5.post2.tar.gz
Algorithm Hash digest
SHA256 09326e4027efacb5f517259ae8ec9e155a1e86a70cf63d608f70b18b6424f114
MD5 60f0e8d43aaab3bbe86a95ee1d25857e
BLAKE2b-256 1386979cf0a315ab6120fb85a117b754f7726fd6a26c7cb74c842222e0eba59b

See more details on using hashes here.

File details

Details for the file ravendb_test_driver-7.2.5.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for ravendb_test_driver-7.2.5.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 9eeaff82b27968f6cf8c0051323714ea5a71c637c3a31a6d2c47d08e20888082
MD5 d37380368cb8bc50bf82aa1b5b660b79
BLAKE2b-256 4e0a671ffd8c89cfc401d9982978360365717ee81901093611763e2709c33957

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

7.2.5.post2 This release

2 files

7.2.5.post1

2 files

7.2.5

2 files

7.2.3

2 files

7.2.2

2 files

7.2.1

2 files

7.2.0

2 files

7.1.5

2 files

7.1.4

2 files

7.1.3

2 files

7.1.2.post1

2 files

7.1.2

2 files

7.0.2

2 files

7.0.0

2 files

6.2.4

2 files

6.0.0.post6

2 files

6.0.0.post5

2 files

6.0.0.post4

2 files

6.0.0.post3

2 files

6.0.0.post2

2 files

6.0.0.post1

2 files

6.0

3 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page