fix(test): skip test_bytesio_at_end_position when soundfile unavailable

The test was using an environment variable SKIP_AUDIO_TESTS to skip
the test, but this doesn't work reliably because:
1. The env var may not be set in all environments
2. The actual dependency check should be for soundfile module

This changes the skipif to check if soundfile can actually be imported,
making the test skip gracefully in environments where soundfile is not
installed while still running in CI where it is available.
This commit is contained in:
shin-bot-litellm 2026-02-01 00:09:31 +00:00
parent 37a45a3295
commit 267cc6307e

View file

@ -210,12 +210,22 @@ class TestProcessAudioFile:
assert result.content_type == "audio/wav"
def _soundfile_available() -> bool:
"""Check if soundfile module is available."""
try:
import soundfile # noqa: F401
return True
except ImportError:
return False
class TestCalculateRequestDuration:
"""Test the calculate_request_duration function"""
@pytest.mark.skipif(
os.environ.get("SKIP_AUDIO_TESTS") == "true",
reason="Skipping audio tests - soundfile may not be available",
not _soundfile_available(),
reason="soundfile module not available",
)
def test_bytesio_at_end_position(self):
"""