menu_book Course Curriculum (Software Testing) expand_more
Testing Fundamentals
Assertions & Fixtures
Test Doubles & Dependencies
Coverage & Quality
API & Web Testing
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
Advertisement
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