Skip to content

feat: add unified unit tests and GitHub Actions CI workflow#697

Merged
steam-bell-92 merged 2 commits into
steam-bell-92:mainfrom
nishtha-agarwal-211:fix/decorative-code-overlapping-474
May 23, 2026
Merged

feat: add unified unit tests and GitHub Actions CI workflow#697
steam-bell-92 merged 2 commits into
steam-bell-92:mainfrom
nishtha-agarwal-211:fix/decorative-code-overlapping-474

Conversation

@nishtha-agarwal-211
Copy link
Copy Markdown
Contributor

Summary

Closes #395

This PR addresses the issue requesting an automated testing system. It sets up a unified pytest-based test suite covering core helper functions across multiple mini-projects, and configures a GitHub Actions workflow to run tests automatically on every Pull Request.


Changes Made

🧪 New: tests/ directory

File What's Tested Tests
tests/conftest.py Adds project root to sys.path for clean imports
tests/test_polar_transform.py format_number, Cartesian→Polar conversion, quadrant detection 25
tests/test_progressions.py parse_sequence, AP / GP / HP / AGP checkers, format_number 22
tests/test_fibonacci.py fibonacci() series generation, build_layout() geometry 12
tests/test_morse.py Dictionary completeness, text→Morse, Morse→text, round-trips 18
tests/test_math_quiz.py is_prime, generate_question, generate_options, get_grade 22

Total: 119 tests, all passing ✅

⚙️ New: CI Workflow

  • .github/workflows/tests.yml — runs pytest tests/ -v --tb=short on every PR and push to main
  • Matrix: Python 3.10, 3.11, 3.12 on ubuntu-latest

📦 New: requirements-dev.txt

  • Adds pytest>=7.0 as a dev dependency

Design Decisions

  • No source files were modified — tests import pure helper functions via importlib.util.spec_from_file_location, which handles hyphenated filenames
  • GUI/I/O isolatedtkinter, turtle, and winsound are mocked with MagicMock; top-level input() / REPL loops are suppressed with unittest.mock.patch

Test Run Output

platform darwin -- Python 3.14.3, pytest-9.0.3
collected 119 items

119 passed in 0.65s

Checklist

  • Tests added for math converters (Polar Transformation, AP/GP/AGP/HP, Fibonacci)
  • Tests added for Morse translator (encode, decode, round-trip)
  • Tests added for Math Quiz logic (prime check, question generation, grading)
  • GitHub Actions workflow configured
  • All 119 tests pass locally
  • No existing source files modified

- Create tests/ directory with pytest-based test suite
- Add test_polar_transform.py: format_number, Cartesian→Polar math, quadrant detection (25 tests)
- Add test_progressions.py: AP/GP/AGP/HP checkers, parse_sequence, format_number (22 tests)
- Add test_fibonacci.py: fibonacci() series generation, build_layout() geometry (12 tests)
- Add test_morse.py: dictionary completeness, encode/decode, round-trip consistency (18 tests)
- Add test_math_quiz.py: is_prime, generate_question, generate_options, get_grade (22 tests)
- Add requirements-dev.txt with pytest>=7.0
- Add .github/workflows/tests.yml: CI runs on every PR/push to main across Python 3.10/3.11/3.12

All 119 tests pass locally (python3 -m pytest tests/ -v)

Closes #<issue-number>
Copilot AI review requested due to automatic review settings May 23, 2026 18:07
@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

@nishtha-agarwal-211 is attempting to deploy a commit to the Anuj's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a test suite and CI workflow to the repository, covering several existing utility/math/game scripts via dynamic module loading (since the source files run I/O or GUI code at import time).

Changes:

  • Adds pytest-based tests for Fibonacci, Math Quiz, Morse, Polar Transform, and AP/GP/AGP/HP Recognizer modules.
  • Adds conftest.py to extend sys.path, and a requirements-dev.txt pinning pytest.
  • Adds a GitHub Actions workflow running tests across Python 3.10–3.12.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/test_progressions.py Tests for AP/GP/AGP/HP recognizer helpers, loaded dynamically.
tests/test_polar_transform.py Tests using re-implemented helpers mirroring the source.
tests/test_morse.py Tests via re-implemented Morse conversion logic.
tests/test_math_quiz.py Tests for Math Quiz module with tkinter/winsound mocked.
tests/test_fibonacci.py Tests for fibonacci/build_layout with turtle mocked.
tests/conftest.py Adds project root to sys.path.
requirements-dev.txt Adds pytest dev dependency.
.github/workflows/tests.yml New CI workflow running pytest on Py 3.10–3.12.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_morse.py
Comment thread tests/test_polar_transform.py
Comment thread tests/test_morse.py
Comment thread tests/test_math_quiz.py
Comment thread tests/test_progressions.py
Comment thread tests/test_progressions.py
Comment thread tests/test_math_quiz.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@steam-bell-92 steam-bell-92 merged commit 19901d7 into steam-bell-92:main May 23, 2026
5 of 9 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution!

Your Pull Request has been merged successfully.

We appreciate the time and effort you put into improving this project. Contributions like yours help the repository grow and stay useful for everyone.

If you'd like to contribute again, please check the open issues and make sure you are assigned before opening another Pull Request.

Thanks again for your support! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Add Automated Unit Testing Framework with Pytest and GitHub Actions

3 participants