Skip to content

Add unit tests for least-covered Python modules + pytest CI - #592

Open
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784905669-python-unit-tests
Open

Add unit tests for least-covered Python modules + pytest CI#592
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1784905669-python-unit-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

The repo has 126 Python modules and effectively 0% test coverage (the only pre-existing test files were a default CRA App.test.js and a stray Java Test.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.py adds a load_module(relative_path, name) helper that loads any script by path via importlib. I targeted the modules with clean, deterministic, side-effect-free logic (guarded by if __name__ == "__main__"), which are the highest-value/lowest-risk to lock down first.

50 tests added across 7 previously-untested modules:

  • Scytale Cipher/cipher.pyencrypt/decrypt, round-trips, key=1 identity, trailing-partial-row drop
  • morse_translator/morse_translator.py — encode/decode round-trips, digit table, KeyError on lowercase input
  • url_shortener/url_shortener.py — md5-prefix short URLs, caching, expand + not-found path
  • Sentiment_analyzer_for_prototypes/sentiment_analyzer.pyclean_text, positive/negative/neutral scoring, word frequency, ASCII cloud
  • Color Palette Generator/main.py — palette length, hex-format validation
  • Hash/hashing.pycalculate_hash vs hashlib for md5/sha1/sha256/sha512, empty/large files, SystemExit on missing file
  • password_generator/password_generator.py — length bounds, per-charset selection, no-option error path

Tests 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 — runs pytest on push/PR touching Python files
  • .gitignore entries for __pycache__/, *.pyc, .pytest_cache/

Run locally:

pip install -r requirements-test.txt && python -m pytest -q
# 50 passed

Link to Devin session: https://app.devin.ai/sessions/e358d5f9691749f781c2b91ff99ee7fa
Requested by: @josharsh

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@josharsh josharsh self-assigned this Jul 24, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions github-actions Bot added python Pull requests that update Python code github-actions labels Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github-actions python Pull requests that update Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant