Python Unit Testing

Some examples of Python Unit testing.

  • Using Makefile

    make test

    Running the tests is not the goal of this project, but the information and the examples of different topics regarding Unit Testing

Topics

  1. Raising exception with pytest
  2. Mock and MagicMock
    1. Difference of Mock() and MagicMock(). Difference in error raised
    2. Mocking an object attribute or Set a value to a mock's attribute
    3. Return value and Side effect
  3. Patch
    1. Patching imported libray
    2. Patching the attribute of a library
  4. Sentinel (TODO)

Reference

  1. Blog | Python Unit tests at Hypothesis : https://www.seanh.cc/2017/01/15/python-unit-tests-at-hypothesis/