- Home
- Skills
- Testing & Debugging
- Pytest Gap Filler: Find Untested Python and Write Tests
Pytest Gap Filler: Find Untested Python and Write Tests
Identify untested Python functions and generate comprehensive pytest suites with edge cases and side-effect isolation.
$7
Works with the AI Agents you already use
Pytest Gap Filler: Find Untested Python and Write Tests
Example session with this skill installed
Scan src/utils and tests/ for untested functions and write tests for the top 3 most complex gaps found.
- Read your context and instructions
- Compiled the pytest gap filler
I have scanned the directories and identified 8 untested public functions. I prioritized calculate_pro_rata_share, parse_config_env, and validate_transaction_hash due to their branching logic and error handling.
Coverage Gap Report
| Function | Complexity | Test File | Cases Added |
|---|---|---|---|
calculate_pro_rata_share | High (Math/Branching) | tests/test_utils.py | 5 |
parse_config_env | Medium (Parsing/IO) | tests/test_utils.py | 4 |
validate_transaction_hash | Medium (Regex/Validation) | tests/test_utils.py | 3 |
import pytest
from src.utils import calculate_pro_rata_share
def test_calculate_pro_rata_share_happy_path():
assert calculate_pro_rata_share(100, [50, 50]) == [50, 50]
@pytest.mark.parametrize("total, weights, expected", [
(100, [1, 1, 1], [33.33, 33.33, 33.34]),
(0, [1, 2], [0, 0]),
])
def test_calculate_pro_rata_share_boundaries(total, weights, expected):
# Testing rounding and zero totals
assert calculate_pro_rata_share(total, weights) == expected
def test_calculate_pro_rata_share_empty_weights():
with pytest.raises(ValueError, match="Weights list cannot be empty"):
calculate_pro_rata_share(100, [])
def test_calculate_pro_rata_share_negative_total():
with pytest.raises(ValueError, match="Total must be non-negative"):
calculate_pro_rata_share(-1, [1, 1])
Next steps
- Review the generated tests in
tests/test_utils.py. - Run the full suite with
pytest tests/test_utils.pyto confirm local environment consistency. - Address the suspected bug in
parse_config_envwhere it fails to handle malformed YAML without a clear error.
Connects securely to your tools. The creator never sees your data.
About this skill
Coverage tools show you what is missing, but they do not write the fix. This skill identifies untested Python functions and generates high-quality pytest suites to close those coverage gaps.
What it does
- Identify gaps by scanning source and test directories for unreferenced public functions and methods.
- Rank priorities to focus on complex logic like branching, parsing, or math over trivial getters.
- Analyze behavior by inspecting inputs, outputs, side effects, and potential exceptions.
- Generate tests including happy paths, boundary cases, and error handling with
pytest.raises. - Isolate side effects using
tmp_path,monkeypatch, andcapsysto ensure hermetic execution. - Verify results by running the new tests and reporting whether failures stem from test logic or actual source bugs.
How it works
- Run the gap detection script to generate a lead list of untested functions.
- Select high-priority targets based on complexity and business logic.
- Inspect the source code to map out inputs, outputs, and edge cases.
- Generate and save new tests to the appropriate
tests/test_*.pyfiles. - Execute the tests and provide a final report on coverage improvements and suspected bugs.
Frameworks & tools
This skill is built for Python projects using the pytest framework. It utilizes standard library tools and pytest fixtures like monkeypatch and tmp_path for isolation.
Why this beats prompting it yourself
Standard prompts often produce generic tests that ignore complex branches or fail due to unhandled side effects. This skill follows a systematic discovery process and uses proper test isolation patterns to ensure generated suites are reliable and maintainable.
Use cases
- Closing coverage gaps in legacy Python modules.
- Generating test suites for newly added features before a pull request.
- Stress-testing complex utility functions with boundary and error cases.
- Identifying and documenting suspected bugs in untested code paths.
Known limitations
Relies on a name-based check for gap detection. Requires a provided scripts/gaps.py or equivalent logic to function.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Testing & Debugging.
Relies on name-based matching for gap detection. Requires scripts/gaps.py to be present in the project.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed today