Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Better cleanup of resources in the test suite#1642

Merged
rolandwalker merged 1 commit intomainfrom
RW/better-test-suite-resource-cleanup
Feb 28, 2026
Merged

Better cleanup of resources in the test suite#1642
rolandwalker merged 1 commit intomainfrom
RW/better-test-suite-resource-cleanup

Conversation

@rolandwalker
Copy link
Contributor

Description

  • name tempfiles with a prefix in case they get left behind
  • use monkeypatch methods to manipulate environment variables, ensuring that state doesn't persist for another test
  • avoid creating file does_not_exist.myclirc
  • explicitly tear down sqlexecute connection in fixture

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Feb 27, 2026
@github-actions
Copy link

Findings (ordered by severity):

  1. Resource leak in updated cleanup test
  • In test/test_config.py, tempfile.mkstemp() returns an open file descriptor, but only the path is used and the fd is never closed.
  • This can leak descriptors during longer test runs and is contrary to the PR’s cleanup goal.
  • Action: capture and close the fd (fd, temp_path = tempfile.mkstemp(); os.close(fd)) or switch to NamedTemporaryFile(delete=False, ...).
  1. Coverage regression for missing pwd_config_file path
  • In test/test_main.py, MyCli.pwd_config_file changed from a non-existent file path to os.devnull.
  • This no longer exercises behavior when the current-directory config is absent; it now exercises behavior with an existing empty file.
  • Action: keep this change if desired for cleanup, but add a separate test for the absent-file edge case (non-existent pwd_config_file) so that path remains covered.

Security concerns:

  • No security issues identified in this PR scope.

Validation note:

  • Could not run tests in this environment because pytest/uv are unavailable on PATH.

@rolandwalker rolandwalker force-pushed the RW/better-test-suite-resource-cleanup branch from d095b27 to 43a5a74 Compare February 27, 2026 11:22
 * name tempfiles with a prefix in case they get left behind
 * use monkeypatch methods to manipulate environment variables,
   ensuring that state doesn't persist for another test
 * avoid creating file "does_not_exist.myclirc"
 * explicitly tear down sqlexecute connection in fixture
@rolandwalker rolandwalker force-pushed the RW/better-test-suite-resource-cleanup branch from 43a5a74 to eadd0f2 Compare February 27, 2026 23:11
@rolandwalker rolandwalker merged commit 3286778 into main Feb 28, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/better-test-suite-resource-cleanup branch February 28, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants