Fix CI failures by updating OSError handling in test finalizers#477
Fix CI failures by updating OSError handling in test finalizers#477Harishmcw wants to merge 1 commit intobastibe:masterfrom
Conversation
|
Can you point me to documentation of this behavior? This seems awfully strange. I'm also a bit saddened that we're no longer checking for the OSError. Perhaps we should explicitly disable the check only on Windows? |
|
Thanks for the question, I investigated this further. I verified that SoundFile correctly closes the file descriptor. After However, on the newer Windows CI environment ( Minimal check I used: Output:
So the FD is definitely closed, but If you prefer, we could keep the check and disable it only on Windows. |
This PR fixes the CI failures on Windows builds.
The Problem
windows-2022but failing onwindows-latestbecause GitHub updated the latter to Windows Server 2025. On this newer image, closing an invalid file descriptor now fails silently instead of raising an OSError. Since the test strictly expected a crash via pytest.raises(OSError), the lack of an exception caused a test failure.The Soultion
tests/test_soundfile.pyto use atry/exceptblock. This ensures the file is closed if still open, but allows the test to pass if the OS handles the closure silently or if the library has already disposed of the resource.