Index
provide.testkit.streams
¶
Stream Testing Utilities.
Provides utilities for redirecting and managing streams during testing.
Functions¶
enable_file_logging_for_testing
¶
Enable file logging specifically for testing scenarios.
This function bypasses the normal testmode detection that prevents file logging during tests. It should only be used in tests that specifically need to test file logging functionality.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_file_path
|
str
|
Path to the log file to write to |
required |
Returns:
| Type | Description |
|---|---|
object
|
Context manager that keeps the file logging enabled |
Note
This is a specialized utility for testing file logging behavior. Most tests should use captured_stderr_for_foundation fixture instead.
Source code in provide/testkit/streams/testing.py
get_current_log_stream
¶
Get the currently active log stream.
Returns:
| Type | Description |
|---|---|
TextIO
|
The current log stream being used by Foundation |
reset_log_stream
¶
set_log_stream_for_testing
¶
Set the log stream for testing purposes.
This allows tests to redirect Foundation's log output to a custom stream (like StringIO) for capturing and verifying log messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stream
|
TextIO | None
|
Stream to redirect to, or None to reset to stderr |
required |