Skip to content

Test coverage: FauxProvider edge cases (abort, no-delta, cache, error) - #57

Merged
xfgong merged 2 commits into
mainfrom
test/faux-provider-coverage
May 10, 2026
Merged

Test coverage: FauxProvider edge cases (abort, no-delta, cache, error)#57
xfgong merged 2 commits into
mainfrom
test/faux-provider-coverage

Conversation

@xfgong

@xfgong xfgong commented May 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add 10 new tests covering previously uncovered lines in cubepi/providers/faux.py
  • Targets lines 147-148, 279-290, 320-325, 340-347, and 425-432

New test classes and cases

TestCanAcceptExtendedArgs (lines 147-148)

  • ValueError and TypeError fallback in _can_accept_extended_args when inspect.signature() fails

TestFauxProviderProduceExceptionHandling (lines 279-290)

  • Factory raising Exception produces error result without re-raise
  • Factory raising BaseException produces error result and re-raises

TestFauxProviderAbortDuringBlocks (lines 320-325, 340-347, 425-432)

  • Abort between content blocks via patched MessageStream.push
  • Abort during thinking chunk streaming
  • Abort during tool call chunk streaming
  • Abort during text block prevents subsequent tool call block

TestFauxProviderCacheTokenCalculation (cache logic)

  • First-call structure: input_tokens == cache_write_tokens, cache_read == 0
  • Full prefix match: cache_read > 0, cache_write == 0, input_tokens == 0
  • Partial prefix change: both cache_read > 0 and cache_write > 0

Test plan

  • pytest tests/ -q -- 310 passed
  • ruff check cubepi/ tests/ -- all checks passed
  • ruff format --check cubepi/ tests/ -- 48 files already formatted

Closes #51

xfgong added 2 commits May 10, 2026 21:28
… paths

Cover previously uncovered lines in providers/faux.py:

- Lines 147-148: _can_accept_extended_args ValueError/TypeError fallback
- Lines 279-290: _produce exception handler for factory errors and
  BaseException re-raise
- Lines 320-325: block-level abort check between content blocks
- Lines 340-347: abort during thinking chunk streaming
- Lines 425-432: abort during tool call chunk streaming
- Cache token calculation: first-call structure, full prefix match,
  and partial prefix change scenarios

Closes #51
Add task exception assertion to BaseException test and refactor three
chunk-abort tests to use synchronous push-patching instead of
consumer-side signal setting, eliminating timing races.
@xfgong
xfgong merged commit c69992b into main May 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test coverage: FauxProvider edge cases (abort, no-delta, cache simulation)

1 participant