Skip to content

test: mock remaining network call in test_encode_invalid_audio_url_chunk - #192

Merged
juliendenize merged 2 commits into
mistralai:mainfrom
abdelhadi703:test/mock-remaining-network-calls
Mar 4, 2026
Merged

juliendenize merged 2 commits into
mistralai:mainfrom
abdelhadi703:test/mock-remaining-network-calls

Conversation

@abdelhadi703

Copy link
Copy Markdown
Contributor

Summary

test_encode_invalid_audio_url_chunk in test_tokenizer_v7_audio.py made a live HTTP request to example.com when testing the invalid-URL error path. This is fragile: it depends on external host availability and can cause non-deterministic CI failures (e.g., SSL certificate verification issues on macOS with uv-managed Python).

This PR replaces the live call with a mocked requests.get that raises RequestException, following the same pattern established by @framsouza in #188 for test_audio.py.

Changes

  • Mock mistral_common.audio.requests.get in test_encode_invalid_audio_url_chunk to simulate a failed network request
  • Add import requests to test_tokenizer_v7_audio.py

Test plan

  • uv run pytest tests/test_tokenizer_v7_audio.py::test_encode_invalid_audio_url_chunk -v passes
  • Full test suite uv run pytest tests/ -v passes (506 passed, 16 skipped)
  • uv run ruff check . and uv run ruff format --check . pass

No behavior changes to production code.

test_encode_invalid_audio_url_chunk made a live HTTP request to
example.com when testing the invalid URL error path. This is fragile
as it depends on external availability and network conditions
(e.g., SSL certificate verification on macOS).

Replace with a mocked response following the same pattern established
in test_audio.py (PR mistralai#188 by @framsouza).

No behavior changes to production code.

@juliendenize juliendenize left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

Comment thread tests/test_tokenizer_v7_audio.py Outdated
@juliendenize
juliendenize merged commit 4f279d6 into mistralai:main Mar 4, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants