Isolate test_files.py outputs per test to fix parallel-run failures#402
Conversation
Each test now writes to its own subdirectory of tests/output_files/ (named after the full test ID), preventing parallel test runs from polluting each other's file sets. Introduce _OutputFilesTestBase with shared setUp/tearDown and assertOutputFiles(expected) so both test classes use set-equality assertions rather than ad-hoc per-file checks. This fixes test failures seen with testflo -n 2 that did not occur on Azure CI (which forces N_TEST=1). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Setting KEEP_OUTPUT_FILES = True at the top of test_files.py skips tearDown cleanup so that output subdirectories and their .cgns/.plt files remain on disk after the test run for manual inspection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
For future reference, here is the prompt I gave to claude to generate this fix and PR:
|
Summary
TestSolutionFileNamesUnsteadyusedassertSetEqualagainst the sharedtests/output_files/directory. Whentestflo -n 2runs tests concurrently, one test's cleanup (_cleanup_output_files) deleted files that another test had just written, and vice versa — causing spurious set-equality failures..github/test_real.shforcesN_TEST=1on Azure Pipelines, so tests always ran sequentially there.tests/output_files/named after the full test ID (viaunittest.TestCase.id()), eliminating all cross-test file pollution._OutputFilesTestBaseshared by both test classes, withassertOutputFiles(expected)using set-equality throughout — replacing the ad-hoc per-fileassertTrue(os.path.isfile(...))checks inTestSolutionFileNames.KEEP_OUTPUT_FILES = Falseflag at the top oftest_files.py; set it toTrueto keep output subdirectories on disk after a run for manual inspection.Test plan
testflo -v unit_tests/test_files.py(sequential) — all 6 passtestflo -v -n 2 unit_tests/test_files.py(parallel) — all 6 pass🤖 Generated with Claude Code