Skip to content
Sharp

Testing · interview question

What does a strong engineer do when reasoning through tmp_path and file tests code?

Multiple choiceHardchapter-9-curatedpremiumtestingtmp-path-and-file-tests
python
def test_writes_report(tmp_path) -> None:
    target = tmp_path / "report.json"
    target.write_text("{}", encoding="utf-8")
    assert target.exists()
Choose one answer
Answer and explanation

Correct answer

A. Narrate the data shape, the state changes, and the exact rule order step by step.

Why

Interviewers often use simple code to test whether you can reason through execution without bluffing.

Test yourself on Testing

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

Start free test
All Testing questions →