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.
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:
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.