Conftest
provide.testkit.conftest
¶
Pytest configuration and fixtures for provide-testkit.
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.
Source code in provide/testkit/hub/fixtures.py
pytest_sessionfinish
¶
Reset terminal state after test session to prevent output corruption.
This hook ensures ANSI escape codes and terminal state are properly reset after pytest completes, preventing garbled output in the terminal.
Common causes of terminal corruption: - pytest-benchmark unicode box-drawing characters - Hypothesis verbose output with special characters - ANSI color codes not properly terminated - pytest-xdist worker output interference
The reset codes used: - \033[0m : Reset all text formatting attributes - \033[?25h : Show cursor (in case it was hidden)