Skip to content

Commit 7ebdeaf

Browse files
committed
Add force_capture
1 parent 380386c commit 7ebdeaf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pytest_textual_snapshot.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def app_stash_key() -> pytest.StashKey:
3939
app_stash_key._key = pytest.StashKey[App]()
4040
return app_stash_key()
4141

42+
4243
@pytest.fixture
4344
def snap_compare(
4445
snapshot: SnapshotAssertion, request: FixtureRequest
@@ -54,6 +55,7 @@ def compare(
5455
press: Iterable[str] = (),
5556
terminal_size: tuple[int, int] = (80, 24),
5657
run_before: Callable[[Pilot], Awaitable[None] | None] | None = None,
58+
force_capture: bool = False,
5759
) -> bool:
5860
"""
5961
Compare a current screenshot of the app running at app_path, with
@@ -69,6 +71,8 @@ def compare(
6971
run_before: An arbitrary callable that runs arbitrary code before taking the
7072
screenshot. Use this to simulate complex user interactions with the app
7173
that cannot be simulated by key presses.
74+
force_capture: True to force enable output capturing. When `headless=True`, output
75+
capturing is disabled. Setting `force_capture=True` overrides this behaviour.
7276
7377
Returns:
7478
Whether the screenshot matches the snapshot.
@@ -92,6 +96,7 @@ def compare(
9296
press=press,
9397
terminal_size=terminal_size,
9498
run_before=run_before,
99+
force_capture=force_capture
95100
)
96101
result = snapshot == actual_screenshot
97102

0 commit comments

Comments
 (0)