Skip to content

R23-T056: Move test_abs_val into doctests and reach 100% coverage for maths/abs.py - #66

Open
code-paul-creator wants to merge 1 commit into
S-AI-Projects:masterfrom
code-paul-creator:R23-T056
Open

code-paul-creator wants to merge 1 commit into
S-AI-Projects:masterfrom
code-paul-creator:R23-T056

Conversation

@code-paul-creator

Copy link
Copy Markdown

Description

Explores how CI collects and reports on maths/abs.py (doctests vs the test_abs_val() function) and closes the coverage gap: test_abs_val's assertions become doctests, and the __main__ block, which pytest never runs, is marked # pragma: no cover.

Related Issue

Fixes: #56

Type of Change

  • Bug Fix
  • New Feature
  • UI/UX Improvement
  • Performance Improvement
  • Tests
  • Documentation
  • Refactoring / Maintenance
  • CI/CD

Changes Made

  • maths/abs.py: added doctests to abs_val, abs_min, abs_max, abs_max_sort (the cases from test_abs_val), removed test_abs_val() and its call in __main__, marked the __main__ block # pragma: no cover (same convention as ciphers/skytale_cipher.py).
  • work/R23-T056/CI_NOTES.md: how CI runs pytest (flags, --ignore, coverage), the collected test IDs, DIRECTORY.md / build_directory_md.py / validate_filenames.py behaviour, and the coverage before/after output.
  • work/R23-T056/coverage_before.txt, coverage_after.txt: full pytest-cov output.

Screenshots / Recordings

Not applicable (no UI changes).

Testing

  • python -m pytest maths/abs.py --cov=maths --cov-report=term-missing -v -> before: 6 items, abs.py below 100% (lines 89-94 missing); after: 4 items, abs.py 100%
  • python -m pytest maths/test_abs.py -q -> passed
  • ruff check maths/abs.py -> all checks passed

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.

Additional Notes

Findings: pytest maths/abs.py collects both the doctests and the test_abs_val function (6 items), but CI-style collection (pytest .) collects only the doctests: abs.py does not match test_*.py, and --doctest-modules is what picks it up, so test_abs_val ran only through its >>> test_abs_val() doctest. The coverage gap was the __main__ block. Side note: abs_val(-0.0) returns -0.0 while built-in abs(-0.0) is 0.0 (not changed). Details in work/R23-T056/CI_NOTES.md.

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.

Paulami Bhosle — R23-T056: How CI tests maths/abs.py

1 participant