.. _session_1_06: ################################################ Session 6: Testing and Advanced Argument Passing ################################################ Unit Testing and Advanced Argument Passing Pre-class prep ============== Reading ------- Unit Testing ............ * :ref:`unit_testing` **NOTE:** you will find that most introductions to unit testing with Python use the built in ``unittest`` module. However, it is a bit heavyweight, and requires some knowledge of OOP -- classes, etc. So we'll be using pytest in this class: http://doc.pytest.org/en/latest/. But the principles of testing are the same. * Dive into Python: chapter 9: http://www.diveintopython3.net/unit-testing.html * Ned Batchelder's intro to testing presentation: - http://nedbatchelder.com/text/test0.html Arguments and Parameters ------------------------ * :ref:`advanced_argument_passing` * arguments and parameters: - http://stupidpythonideas.blogspot.com/2013/08/arguments-and-parameters.html - https://pythontips.com/2013/08/04/args-and-kwargs-in-python-explained/ In-class Activities =================== :ref:`a_bit_on_mutability` Exercises: ---------- * :ref:`exercise_unit_testing` * :ref:`exercise_args_kwargs_lab` Testing mailroom: ................. :ref:`exercise_mailroom_part4_testing` Write a complete set of unit tests for your mailroom program. * You will likely find that it is really hard to test without refactoring. * This is Good! * If code is hard to test -- it probably should be refactored. Post-class Activities ===================== Finish the exercises Look at the next session for reading, etc: :ref:`session_1_07` NOTE: there is not a lot of new stuff this week, but this will give all of you a chance to catch up if you don't have mailroom and trigrams fully working yet. And do spend time with the readings (and supplemental readings) -- we are going to dive right in to OO programming next week.