gammasim / simtools

Tools and applications for the Simulation System of the CTA Observatory.
https://gammasim.github.io/simtools
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

Fix failing unit tests (random order, multiple in parallel) in test_mirror_panel_psf #1226

Closed GernotMaier closed 2 weeks ago

GernotMaier commented 2 weeks ago

The random order / multiple in parallel run of the unit tests fails (see e.g., https://github.com/gammasim/simtools/actions/runs/11733865571/job/32700665445) for test_mirror_panel_psf.

This PR fixes the issue by isolating the mocked object correctly inside a with block.

To test this PR do:

pytest --random-order --count 50 -n auto --no-cov tests/unit_tests/ray_tracing/test_mirror_panel_psf.py

As a side note: to identify that this is a shared instance issue, I found the package pytest-forked useful. It allows to separate pytest processes with --forked. As this was successful, it was clear that a shared instance was the problem.

ctao-dpps-sonarqube[bot] commented 2 weeks ago

Passed

Analysis Details

0 Issues

Coverage and Duplications

Project ID: gammasim_simtools_AY_ssha9WiFxsX-2oy_w

View in SonarQube

GernotMaier commented 2 weeks ago

Thank you!