Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Add doctests to your own code

  • Pick a module from your own code and create a backup copy. (from work)
  • Add a function called 'self_test' that uses 'assert' to test some of the real functions of the module.
  • Add code that will run the 'self_test' when the file is executed as a script.
  • Add documentation to one of the functions and convert the 'assert'-based tests to doctests.
  • Convert the mechanism that executed the 'self_test' to run the doctests as well.
  • Let me know what are the dificulties!