Add unit tests for least-covered Python modules + pytest CI - #592
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Add unit tests for least-covered Python modules + pytest CI#592devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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
The repo has 126 Python modules and effectively 0% test coverage (the only pre-existing test files were a default CRA
App.test.jsand a stray JavaTest.java). This PR bootstraps a Python test suite and CI.Since the projects are standalone scripts in directories with spaces (not importable packages),
tests/conftest.pyadds aload_module(relative_path, name)helper that loads any script by path viaimportlib. I targeted the modules with clean, deterministic, side-effect-free logic (guarded byif __name__ == "__main__"), which are the highest-value/lowest-risk to lock down first.50 tests added across 7 previously-untested modules:
Scytale Cipher/cipher.py—encrypt/decrypt, round-trips, key=1 identity, trailing-partial-row dropmorse_translator/morse_translator.py— encode/decode round-trips, digit table,KeyErroron lowercase inputurl_shortener/url_shortener.py— md5-prefix short URLs, caching, expand + not-found pathSentiment_analyzer_for_prototypes/sentiment_analyzer.py—clean_text, positive/negative/neutral scoring, word frequency, ASCII cloudColor Palette Generator/main.py— palette length, hex-format validationHash/hashing.py—calculate_hashvshashlibfor md5/sha1/sha256/sha512, empty/large files,SystemExiton missing filepassword_generator/password_generator.py— length bounds, per-charset selection, no-option error pathTests assert the code's actual behavior (verified by running each function), so they document real behavior rather than forcing a spec.
Also added:
pytest.ini(testpaths=tests),requirements-test.txt(pytest pinned).github/workflows/python-tests.yml— runspyteston push/PR touching Python files.gitignoreentries for__pycache__/,*.pyc,.pytest_cache/Run locally:
Link to Devin session: https://app.devin.ai/sessions/e358d5f9691749f781c2b91ff99ee7fa
Requested by: @josharsh