Repository navigation
Conversation
…e Tracker/expense.py
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.
Fix(Expense Tracker): Modularize expense tracker, add oracle validation suite, and safe headless import
Summary
Refactors
Expense Tracker/expense.pyto decouple SQLite database setup and Tkinter GUI layout from module root, enables headless and test environment execution without_tkintercrashes, adds an independent oracle validation test suite with 22 boundary/domain inputs, and introduces a focused verification runner.Description
Previously,
Expense Tracker/expense.pyexecuted database creation on disk (Expense Tracker.db), instantiatedroot = Tk(), and blocked inroot.mainloop()unconditionally at module root. This prevented automated testing and caused crashes on headless environments or Python versions without Tkinter support.The changes are as follows:
if __name__ == '__main__': main()to allow safe headless imports without_tkintercrashes or side-effects.list_all_expenses(conn=None, tree=None)to support passing custom/in-memory connections and mock tree widgets, while retaining 100% backward compatibility with global variables and returning the fetched rows for programmatic assertions.init_db(db_path)andcreate_gui(conn, cur)to decouple database setup and widget instantiation.Expense Tracker/tests/test_expense.pycontaining 18 unit tests covering:work/R35-T053/check.pyand saved execution artifacts inwork/R35-T053/.Checks
in the repository
[✓] Made no changes that degrades the functioning of the repository
[✓] Gave each commit a better title (unlike updated README.md)
in the PR
[✓] Followed the format of the pull_request_template
[✓] Made the Pull Request in a small level (for the creator's welfare)
[✓] Tested the changes you made:
python3 -m unittest Expense Tracker/tests/test_expense.py(18 tests, all passing)Note for upstream release: The task runner directory
work/R35-T053/can be removed on a later upstream branch via:git rm -r work/R35-T053/ git commit -m "chore: remove work/R35-T053 runner artifacts for upstream release"