Master programming syntax, solve interactive challenges & run live code in Syntaxis Explore Arena →
menu_book Course Curriculum (Software Testing) expand_more
Software Testing / Test Doubles & Dependencies

mock external API

Learn mock external API in Software Testing with a dedicated explanation, a concept-specific example, practical cautions, and a mastery check.

12 min read • Intermediate
software-testing-018.py
python
from unittest.mock import Mock
http=Mock(); http.get.return_value.json.return_value={'temp':24}
assert http.get('/weather').json()['temp']==24
http.get.assert_called_once_with('/weather')
What to watch
Content source & attribution
Original Syntaxis Content · Original Syntaxis Content