Writing simple (py)tests

Writing simple (py)tests#

Learning Objectives#

After working through this topic, you should be able to:

  • write tests for your functions that pytest recognizes

  • write simple, yet meaningful tests for your functions

  • run them using pytest for your own projects

By “simple, yet meaningful tests” we mean that the input you provide in the tests is valid and should not cause the function to raise errors. Furthermore, this means writing one test per set of input parameters and corresponding expected output (i.e., no reuse of test functions, no reuse of input parameters).

Materials#

Here is the Screencast and these are the slides.

Quiz#