Chapter Review Questions

Chapter Review Questions#

  1. What naming convention must a test file follow for pytest to discover it automatically?

  2. What naming convention must a test function follow?

  3. What happens when an assert statement fails inside a test function?

  4. Write a test function that verifies abs(-5) == 5.

  5. pytest.raises.

    1. What does pytest.raises(ValueError) do?

    2. When would you use it?

  6. What is the difference between a unit test and an integration test?

  7. Give three examples of edge cases you should always consider when writing tests for a numeric function.

  8. Why is it generally better to have one assertion per test function rather than many?

  9. How do you run only the tests in a file called test_strings.py from the command line?