All quizzes
Free quiz · 21 questions in the bank

unittest quiz

Test your unittest knowledge with a free interactive quiz — 21 questions with answers and explanations. No signup needed to play.

Question 1/12Score 0

What is `unittest`?

In this round
  1. What is `unittest`?
  2. What is the purpose of `Mock` objects (from `unittest.mock`), independent of `patch`?
  3. What is the difference between `assertEqual` and using a plain `assert` statement in a unittest test?
  4. What is the purpose of `side_effect` on a `Mock` object?
  5. How does test discovery (`python -m unittest discover`) find test files by default?
  6. What is the purpose of the `setUp` method on a `TestCase`?
  7. What happens when a test method raises an unexpected exception that is NOT explicitly asserted against with `assertRaises`?
  8. What is the purpose of `tearDown`, and when does it run relative to a test method?
  9. What does `assertIn` check?
  10. What is the difference between `setUp`/`tearDown` and `setUpClass`/`tearDownClass`?
  11. What is a key limitation of `unittest` compared to `pytest`, a popular third-party alternative?
  12. What does `assertAlmostEqual` address that `assertEqual` does not handle well?
Gaps to close?
Read the curated unittest notes — core concepts, patterns, interview prep.
unittest notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web