Quiz on Advanced Unit Testing Techniques

Test your grasp on the advanced techniques in Pytest.

We'll cover the following

Coding question

Write a test for the DataFetcher class using pytest and mock the external HTTP request using the pytest-mock library.

Here are the test scenarios you need to cover:

  • Mock the requests.get() function to return a custom JSON response when the fetch_data() method is called with a successful status code (200).

  • Mock the requests.get() function to return None when the fetch_data() method is called with an unsuccessful status code (non-200).

Get hands-on with 1200+ tech skills courses.