Skip to content

Write the files of the unit tests to temporary directories - #638

Merged
yguclu merged 6 commits into
develfrom
yguclu-tests-tmp-path
Nov 3, 2026
Merged

yguclu merged 6 commits into
develfrom
yguclu-tests-tmp-path

Conversation

@yguclu

@yguclu yguclu commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

With pytest 9.2.0, pytest-xdist 3.8.0 ignores the xdist_group mark, so --dist loadgroup no longer keeps the tests of a group on the same worker. The post-processing tests, which wrote files with fixed names to the working directory, could then overwrite or delete each other's files, and failed randomly in CI (fixes #637). To prevent similar problems, the other unit tests which wrote files to the working directory (or to the test folder) now use temporary directories as well.

  • In the unit tests, write all files (YAML, HDF5, VTK, PDF, PNG) to the tmp_path fixture, or to mpi_tmp_path in the MPI tests, and remove the xdist_group markers and the manual cleanup; in test_tensor.py, the image compared with the reference is saved to a temporary directory instead of the test folder
  • Remove the option --dist loadgroup from the command psydac test, as no test uses xdist_group any more (the coverage step on macOS never used it)
  • Remove unused imports in the changed files

Locally, with pytest 9.2.0 and -n auto, the previous versions of psydac/api/tests/test_postprocessing.py and psydac/api/tests/test_build_derham_mapping.py failed 20 to 29 of 51 tests in each run, while the new versions passed all of them in three runs. The changed MPI tests also pass (225 post-processing tests and 65 tests in test_eval_fields_parallel.py and test_discrete_mapping.py on 2 processes, and test_tensor.py on 4 processes).

@yguclu yguclu added the Next Release Must be in next release label Nov 2, 2026
@yguclu
yguclu marked this pull request as ready for review November 2, 2026 12:19
@codacy-production

codacy-production Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

🟢 Coverage 57.81% diff coverage · -0.02% coverage variation

Metric Results
Coverage variation ✅ -0.02% coverage variation
Diff coverage ✅ 57.81% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (4868f6c) 52356 33650 64.27%
Head commit (d83041e) 104622 (+52266) 67224 (+33574) 64.25% (-0.02%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#638) 64 37 57.81%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@yguclu
yguclu marked this pull request as draft November 2, 2026 14:31
@yguclu yguclu changed the title Write the files of the post-processing tests to temporary directories Write the files of the unit tests to temporary directories Nov 2, 2026
@yguclu
yguclu marked this pull request as ready for review November 2, 2026 17:42
@yguclu
yguclu requested a review from kvrigor November 2, 2026 17:42
@yguclu
yguclu merged commit 18457d2 into devel Nov 3, 2026
10 checks passed
@yguclu
yguclu deleted the yguclu-tests-tmp-path branch November 3, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Next Release Must be in next release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post-processing tests fail randomly with pytest 9.2.0

2 participants