Coverage for src / ocarina / aggregates / tests_layers.py: 62.50%

8 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-06-04 16:22 +0200

1"""Helper functions for test results hierarchy.""" 

2 

3from typing import TYPE_CHECKING, Any, TypeGuard 

4 

5from ocarina.railway.result import Fail, Ok 

6 

7if TYPE_CHECKING: 

8 from ocarina.custom_types.oc_test_layers import TestResult 

9 

10 

11def is_test_result_ok(result: TestResult) -> TypeGuard[Ok[Any]]: 

12 """Check if test passed, narrowing type to Ok[Any].""" 

13 return isinstance(result, Ok) 

14 

15 

16def is_test_result_fail(result: TestResult) -> TypeGuard[Fail]: 

17 """Check if test failed, narrowing type to Fail.""" 

18 return isinstance(result, Fail) 

19 

20 

21def is_test_result_skipped(result: TestResult) -> TypeGuard[None]: 

22 """Check if test was skipped, narrowing type to None.""" 

23 return result is None