Skip to content

Fix tempfile leak in behave test suite#1662

Merged
rolandwalker merged 1 commit intomainfrom
RW/prefer-namedtemporaryfile
Feb 28, 2026
Merged

Fix tempfile leak in behave test suite#1662
rolandwalker merged 1 commit intomainfrom
RW/prefer-namedtemporaryfile

Conversation

@rolandwalker
Copy link
Contributor

Description

Fix tempfile leak in behave test suite, preferring NamedTemporaryFile over mkstemp.

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 28, 2026
@github-actions
Copy link

  1. Cleanup can still leak temp files on failure path (low)
  • In test/test_config.py:113, deletion happens only after the assertion succeeds.
  • If get_mylogin_cnf_path() returns unexpected output and the assert at line 116 fails, cleanup at lines 118-122 never runs, so the temp file leaks (the exact issue this PR is trying to address).
  • Action: wrap the assertion block in try/finally (or use tmp_path) and do unconditional cleanup in finally; avoid swallowing cleanup errors with print.

No security issues found in this PR diff.

Testing gap:

  • I could not run tests in this environment because pytest is not installed (pytest: command not found), so runtime verification is pending.

@rolandwalker rolandwalker force-pushed the RW/prefer-namedtemporaryfile branch from 1a1170e to bb29d5f Compare February 28, 2026 17:10
@rolandwalker rolandwalker force-pushed the RW/prefer-namedtemporaryfile branch from bb29d5f to 3566dd4 Compare February 28, 2026 17:12
preferring NamedTemporaryFile over mkstemp
@rolandwalker rolandwalker force-pushed the RW/prefer-namedtemporaryfile branch from 3566dd4 to 63c7f42 Compare February 28, 2026 23:40
@rolandwalker rolandwalker merged commit 320fb6e into main Feb 28, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/prefer-namedtemporaryfile branch February 28, 2026 23:45
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