Testing & Project Structure — Final Exam

14 questions · pass mark 80% · 20 minute limit. The timer auto-submits at zero.

Time remaining: 20:00
  1. Question 1easy

    How does a pytest test assert an expected value?

  2. Question 2easy

    Why should you NOT assert on the exact text an LLM returns?

  3. Question 3medium

    What does a pytest fixture do?

  4. Question 4medium

    What is `@pytest.mark.parametrize` used for?

  5. Question 5medium

    How do you assert that a call raises a ValueError in pytest?

  6. Question 6hard

    Why mock the LLM/HTTP call in tests?

  7. Question 7medium

    What does pytest's `monkeypatch.setattr(assistant, 'call_llm', fake)` accomplish?

  8. Question 8medium

    In a layered AI app, what belongs in the `domain/` layer?

  9. Question 9medium

    What is the main testability benefit of putting the LLM client in an `adapters/` layer?

  10. Question 10hard

    Why use `?` placeholders in `conn.execute("INSERT INTO runs VALUES (?, ?)", (id, score))`?

  11. Question 11medium

    What is mypy?

  12. Question 12easy

    Which Python functions convert between a dict and a JSON string?

  13. Question 13medium

    Name the Python test framework taught here (whose tests are `test_*` functions with plain asserts).

  14. Question 14hard

    One word: keeping domain logic free of framework/vendor imports so it can be tested and swapped is the principle of ____ (the app quality this promotes).

0 / 14 answered