Skip to content

Fix tempfile test isolation for Python 3.13 + CodSpeed benchmark instrumentation#370

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/sub-pr-369
Draft

Fix tempfile test isolation for Python 3.13 + CodSpeed benchmark instrumentation#370
Copilot wants to merge 5 commits intomainfrom
copilot/sub-pr-369

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

Benchmark CI failing on dependency update PR #369 due to test_positional_arg_invalid_commit returning exit code 0 instead of expected 1 when running with Python 3.13 and CodSpeed v4.10.5's memory profiling instrumentation.

Changes

Test isolation improvements:

  • Explicitly close temp files before reading (file descriptor sync issue in Python 3.13 under instrumentation)
  • Restore sys.argv after each test (prevents state pollution across benchmark iterations)
  • Applied pattern to all 6 tempfile-based tests for consistency

Before:

with tempfile.NamedTemporaryFile(mode="w", delete=False) as f:
    f.write("invalid commit message without type")
    f.flush()
    
    try:
        sys.argv = ["commit-check", f.name]
        result = main()
        assert result == 1
    finally:
        os.unlink(f.name)

After:

original_argv = sys.argv.copy()

f = tempfile.NamedTemporaryFile(mode="w", delete=False)
try:
    f.write("invalid commit message without type")
    f.close()  # Explicit close before read
    
    sys.argv = ["commit-check", f.name]
    result = main()
    assert result == 1
finally:
    os.unlink(f.name)
    sys.argv = original_argv  # Restore state

Files Modified

  • .gitignore - Add .codspeed/ to exclude benchmark artifacts
  • tests/main_test.py - Fix 6 tests: test_message_validation_from_file, test_main_with_message_file_argument, and all 4 TestPositionalArgumentFeature tests

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Fix Benchmark CI issue in dependency update PR Fix tempfile test isolation for Python 3.13 + CodSpeed benchmark instrumentation Feb 9, 2026
Copilot AI requested a review from shenxianpeng February 9, 2026 07:22
@github-actions github-actions bot added the bug Something isn't working label Feb 9, 2026
Bumps [CodSpeedHQ/action](https://github.com/codspeedhq/action) from 4.10.2 to 4.10.5.
- [Release notes](https://github.com/codspeedhq/action/releases)
- [Changelog](https://github.com/CodSpeedHQ/action/blob/main/CHANGELOG.md)
- [Commits](CodSpeedHQ/action@2084259...9a74b6b)

---
updated-dependencies:
- dependency-name: CodSpeedHQ/action
  dependency-version: 4.10.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
@shenxianpeng shenxianpeng force-pushed the dependabot/github_actions/CodSpeedHQ/action-4.10.5 branch from ce0ec77 to bc6cffc Compare February 14, 2026 17:49
Copilot AI and others added 3 commits February 14, 2026 19:57
Explicitly close temp file before reading and restore sys.argv after test
to ensure proper isolation in benchmark runs with CodSpeed.

Co-authored-by: shenxianpeng <[email protected]>
Explicitly close temp files before reading and restore sys.argv after tests
to ensure proper isolation across all tests using temp files. This prevents
potential file descriptor issues in Python 3.13 with CodSpeed instrumentation.

Co-authored-by: shenxianpeng <[email protected]>
@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (dependabot/github_actions/CodSpeedHQ/action-4.10.5@bc6cffc). Learn more about missing BASE report.

Additional details and impacted files
@@                                  Coverage Diff                                  @@
##             dependabot/github_actions/CodSpeedHQ/action-4.10.5     #370   +/-   ##
=====================================================================================
  Coverage                                                      ?   94.65%           
=====================================================================================
  Files                                                         ?        9           
  Lines                                                         ?      805           
  Branches                                                      ?        0           
=====================================================================================
  Hits                                                          ?      762           
  Misses                                                        ?       43           
  Partials                                                      ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Base automatically changed from dependabot/github_actions/CodSpeedHQ/action-4.10.5 to main February 14, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants