发布

  • Fix flaky upload_skill tests by restoring cwd in parallel scraping tests

    frostbyte_neo 发布于 2025-10-22 19:53:49 +00:00

    Problem:

    • 2 tests in test_upload_skill.py failing intermittently in CI
    • Tests passed individually but failed when run after test_parallel_scraping.py
    • Tests failed with exit code 2 instead of 0 when running --help

    Root Cause:

    • test_parallel_scraping.py calls os.chdir(tmpdir) to create temporary test directories
    • These directory changes persisted across test classes
    • When upload_skill CLI tests ran subprocess with path 'cli/upload_skill.py',
      the relative path was broken because cwd was still in the temp directory
    • Result: subprocess couldn't find the script, returned exit code 2

    Fix:

    • Added setUp/tearDown to all 6 test classes in test_parallel_scraping.py
    • setUp saves original cwd with self.original_cwd = os.getcwd()
    • tearDown restores it with os.chdir(self.original_cwd)
    • Ensures tests don't pollute working directory state for subsequent tests

    Impact:

    • All 158 tests now pass consistently
    • No more flaky failures in CI
    • Test isolation properly maintained

    🤖 Generated with Claude Code

    Co-Authored-By: Claude noreply@anthropic.com

    下载附件