Files
cleveragents-core/features/validation_pipeline_stream_coverage.feature
T
2026-02-25 10:03:57 +00:00

77 lines
3.0 KiB
Gherkin

@unit @coverage @validation_pipeline
Feature: Validation pipeline _ThreadLocalStream coverage
As a developer maintaining the validation pipeline
I want to exercise the _ThreadLocalStream helper methods
So that all stream-interface methods have coverage
Background:
Given a thread-local stream wrapping a mock original stream
# --- encoding property ---------------------------------------------------
Scenario: encoding property returns the original stream encoding
Given the original stream has encoding "utf-8"
When I read the thread-local stream encoding
Then the encoding should be "utf-8"
Scenario: encoding property falls back to utf-8 when original has no encoding
Given the original stream has no encoding attribute
When I read the thread-local stream encoding
Then the encoding should be "utf-8"
# --- writable method -----------------------------------------------------
Scenario: writable returns True
When I check if the thread-local stream is writable
Then writable should return True
# --- readable method -----------------------------------------------------
Scenario: readable returns False
When I check if the thread-local stream is readable
Then readable should return False
# --- flush method with active buffer -------------------------------------
Scenario: flush flushes the capture buffer when capturing is active
Given capture is started on the thread-local stream
When I write "hello" to the thread-local stream
And I flush the thread-local stream
Then the flush should succeed without error
# --- flush method without active buffer ----------------------------------
Scenario: flush flushes the original stream when no capture is active
When I flush the thread-local stream
Then the original stream flush should be called
# --- isatty method -------------------------------------------------------
Scenario: isatty delegates to the original stream
Given the original stream isatty returns True
When I check if the thread-local stream isatty
Then isatty should return True
Scenario: isatty returns False when original returns False
Given the original stream isatty returns False
When I check if the thread-local stream isatty
Then isatty should return False
# --- write with and without capture ------------------------------------
Scenario: write without capture goes to original stream
When I write "direct output" to the thread-local stream
Then the original stream should have received "direct output"
Scenario: write with capture goes to capture buffer
Given capture is started on the thread-local stream
When I write "captured output" to the thread-local stream
And capture is stopped on the thread-local stream
Then the captured text should be "captured output"
# --- stop_capture when no capture was started ----------------------------
Scenario: stop_capture returns empty string when no capture was started
When capture is stopped on the thread-local stream
Then the captured text should be empty