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_URLRAVENDB_TEST_SERVER_CERTRAVENDB_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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ravendb_test_driver-7.2.5.post2.tar.gz.
File metadata
- Download URL: ravendb_test_driver-7.2.5.post2.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
09326e4027efacb5f517259ae8ec9e155a1e86a70cf63d608f70b18b6424f114
|
|
| MD5 |
60f0e8d43aaab3bbe86a95ee1d25857e
|
|
| BLAKE2b-256 |
1386979cf0a315ab6120fb85a117b754f7726fd6a26c7cb74c842222e0eba59b
|
File details
Details for the file ravendb_test_driver-7.2.5.post2-py3-none-any.whl.
File metadata
- Download URL: ravendb_test_driver-7.2.5.post2-py3-none-any.whl
- Upload date:
- Size: 13.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eeaff82b27968f6cf8c0051323714ea5a71c637c3a31a6d2c47d08e20888082
|
|
| MD5 |
d37380368cb8bc50bf82aa1b5b660b79
|
|
| BLAKE2b-256 |
4e0a671ffd8c89cfc401d9982978360365717ee81901093611763e2709c33957
|