Index
provide.testkit.hub
¶
Hub testing utilities.
Functions¶
default_container_directory
¶
Provides a default directory for container operations in tests.
This fixture is used by tests that need a temporary directory for container-related operations.
Source code in provide/testkit/hub/fixtures.py
isolated_container
¶
Create an isolated Container for dependency injection testing.
This fixture provides a fresh Container instance for each test, eliminating the need for global state resets between tests.
Returns:
| Name | Type | Description |
|---|---|---|
Container |
Any
|
A new Container instance with no pre-registered dependencies. |
Example
def test_my_component(isolated_container): ... # Register test-specific dependencies ... isolated_container.register("my_service", MyService()) ... # Test with isolated state ... service = isolated_container.resolve("my_service") ... assert service is not None
Note
Tests using this fixture do not need to call reset_foundation_setup_for_testing() as each test gets a fresh container automatically.
Source code in provide/testkit/hub/fixtures.py
isolated_hub
¶
Create an isolated Hub with fresh registries for testing.
This fixture provides a Hub instance with isolated registries, enabling dependency injection testing without global state side effects.
Returns:
| Name | Type | Description |
|---|---|---|
Hub |
Any
|
A Hub instance with isolated registries. |
Example
def test_with_di(isolated_hub): ... # Hub has fresh, isolated state ... client = UniversalClient(hub=isolated_hub) ... # Test proceeds without affecting global Hub ... response = await client.get("https://api.example.com") ... assert response.status == 200
Note
This fixture is ideal for unit tests that need Hub functionality but want complete isolation from other tests. No reset functions are needed when using this fixture.