Skip to content
Sharp

Testing · interview question

A bug appears around monkeypatching and mocks. What is the strongest first debugging move?

Multiple choiceMediumchapter-9-curatedpremiumtestingmonkeypatching-and-mocks
python
def test_reads_env(monkeypatch) -> None:
    monkeypatch.setenv("ORDER_OPS_MODE", "test")
    assert load_mode() == "test"
Choose one answer
Answer and explanation

Correct answer

A. Trace one concrete example, inspect the state transitions, and compare them to the intended rule before rewriting anything.

Why

That approach is reliable because it creates evidence. If you mock the behavior you are trying to verify, the test mostly confirms your own setup.

Test yourself on Testing

A free test with instant, explained results. No account needed.

Start free test
All Testing questions →