test-fix
test-fix
Diagnose and fix failing tests following pplx-sdk testing conventions.
When to use
Use this skill when pytest tests fail and you need to identify the root cause and apply the correct fix.
Instructions
- Read the failure output carefully — identify the root cause (assertion error, import error, missing mock, timeout, etc.).
- Locate the source code the test exercises — the fix may be in the source, not the test itself.
- Follow existing patterns: Look at passing tests in the same file for mock setup and assertion style.
- Preserve test intent: Never weaken assertions to make tests pass. Fix the underlying issue.
- Run the fix: Execute
pytest tests/<file> -vto confirm the fix works.
Project Testing Conventions
- Framework: pytest with
pytest-asyncioandpytest-httpx - HTTP mocking: Use
HTTPXMockfrompytest-httpxfor transport tests - Fixtures: Common fixtures in
tests/conftest.py—mock_auth_token,mock_context_uuid,mock_frontend_uuid,mock_backend_uuid - Test naming:
test_<what>_<behavior>(e.g.,test_http_transport_auth_error) - Structure: Arrange-Act-Assert pattern
- No docstrings needed in test files (per ruff config)
Exception Testing
Verify the exception hierarchy when testing error cases:
# AuthenticationError is a TransportError which is a PerplexitySDKError
with pytest.raises(AuthenticationError) as exc_info:
transport.request("GET", "/api/test")
assert exc_info.value.status_code == 401
Common Issues
| Symptom | Likely Cause | Fix |
|---|---|---|
ImportError |
Module restructured | Update import path |
AttributeError |
Model field renamed | Check domain/models.py |
HTTPXMock not matching |
URL or method mismatch | Verify mock URL matches request |
TransportError vs RuntimeError |
Exception type changed | Use pplx_sdk.core.exceptions types |
More from pv-udpv/pplx-sdk
code-analysis
Deep code analysis for pplx-sdk — parse Python AST, build dependency graphs, extract knowledge graphs, detect patterns, and generate actionable insights about code structure, complexity, and relationships. Use when analyzing code quality, mapping dependencies, or building understanding of the codebase.
19spa-reverse-engineer
Reverse engineer Single Page Applications built with React + Vite + Workbox — analyze SPA internals via Chrome DevTools Protocol (CDP), write browser extensions, intercept service workers, and extract runtime state for SDK integration.
19sse-streaming
Implement and debug SSE (Server-Sent Events) streaming for the Perplexity AI API, including parsing, reconnection, and retry logic.
18reverse-engineer
Reverse engineer Perplexity AI web APIs — intercept browser traffic, decode undocumented endpoints, map request/response schemas, extract auth flows, and translate discoveries into SDK code.
18api-design-principles
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.
18ast-grep
Guide for writing ast-grep rules to perform structural code search and analysis. Use when users need to search codebases using Abstract Syntax Tree (AST) patterns, find specific code structures, or perform complex code queries that go beyond simple text search. This skill should be used when users ask to search for code patterns, find specific language constructs, or locate code with particular structural characteristics.
17