feat: add pytest test suite for 3 Python scripts#2247
Open
AnandSundar wants to merge 1 commit into
Open
Conversation
Introduces a pytest-based test suite for the three build-helper scripts
in scripts/ that have no network dependencies:
- Generate_CheatSheets_TOC.py
- Update_CheatSheets_Index.py
- Generate_Technologies_JSON.py
Each script is minimally refactored to expose pure helper functions
(to_display_name, parse_index_line, group_by_letter, etc.) and to
wrap its imperative top-level code in a main() function with
parameterized paths. Byte-for-byte output of the original scripts is
preserved when invoked from the scripts/ directory.
The test suite covers 56 cases (unit + integration), including:
- helper-function unit tests (display names, language detection,
letter grouping, whitespace cleanup, line parsing)
- main() integration tests against fixture cheatsheet directories
- mocked HTTP path for Generate_Technologies_JSON.main()
Files added:
- pytest.ini, requirements-dev.txt
- tests/__init__.py, tests/conftest.py
- tests/test_*.py for the three scripts
The remaining two scripts (Generate_RSS_Feed.py, Identify_Old_Issue_And_PR.py)
and a CI workflow that runs pytest on PRs are deferred to follow-up PRs.
AI assistance: this change was developed with the help of an AI coding
assistant. The refactor, tests, and commit message were reviewed by the
author before submission.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a pytest test suite for the three Python build-helper scripts in
scripts/that have no network dependencies:Generate_CheatSheets_TOC.py,Update_CheatSheets_Index.py, andGenerate_Technologies_JSON.py. Also establishes the pytest infrastructure (config + dev-dependencies file + test directory) the project currently lacks.Each script is minimally refactored to expose pure helper functions (
to_display_name,parse_index_line,group_by_letter, etc.) and to wrap its imperative top-level code in amain()function with parameterized paths. The refactor preserves byte-for-byte output of the original scripts when invoked from thescripts/directory — verified via smoke test against the realcheatsheets/directory.What's in this PR
main()that returns an exit code, with anif __name__ == "__main__":guard. No behavioral change for the existing CLI usage.main()end-to-end. HTTP is mocked with stdlibunittest.mock; no new runtime dependencies.pytest.ini,requirements-dev.txt): kept separate fromrequirements.txtso the production image does not pull in pytest..gitignorecleanup:__pycache__/,*.pyc, anddocs/plans/are now ignored (the latter keeps working-tree planning notes out of the repo).Test results
python -m pytestexits 0PR scope-check compliance
md_lint_check.ymlworkflow is unaffected)Out of scope (deferred to follow-up PRs)
Generate_RSS_Feed.pyandIdentify_Old_Issue_And_PR.py(network-dependent; mocking pattern is established by this PR)..github/workflows/test-python.ymlto run pytest on every PR. Best added after the suite is broader.