Bird
0
0

Which Python library is commonly used to mock external HTTP calls in Flask tests?

easy📝 Conceptual Q2 of 15
Flask - Testing Flask Applications
Which Python library is commonly used to mock external HTTP calls in Flask tests?
Arequests
Bunittest.mock
Cflask.testing
Dflask_sqlalchemy
Step-by-Step Solution
Solution:
  1. Step 1: Identify mocking libraries in Python

    The standard library unittest.mock provides tools to replace parts of your system under test with mock objects.
  2. Step 2: Recognize its use in Flask tests

    unittest.mock is widely used to mock external HTTP calls like requests.get in Flask testing.
  3. Final Answer:

    unittest.mock -> Option B
  4. Quick Check:

    Mocking library = unittest.mock [OK]
Quick Trick: Use unittest.mock to patch external calls easily [OK]
Common Mistakes:
MISTAKES
  • Confusing requests as a mocking tool
  • Using flask_sqlalchemy for mocking
  • Assuming flask.testing mocks HTTP calls

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes