From 94d63bd41bff4ed5351addb478cd2e9d40be38dd Mon Sep 17 00:00:00 2001 From: James Alexander Hughes Date: Wed, 20 Nov 2024 12:41:20 -0400 Subject: [PATCH] :mortar_board: Labs --- Split last labs (#653) --- site/index.rst | 1 + site/labs/objects/data-structures.rst | 16 ++++--- site/labs/objects/objects.rst | 23 ---------- site/labs/testing/unittest-objects.rst | 63 ++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 30 deletions(-) create mode 100644 site/labs/testing/unittest-objects.rst diff --git a/site/index.rst b/site/index.rst index eb4e3ca8..d675cb9a 100644 --- a/site/index.rst +++ b/site/index.rst @@ -97,6 +97,7 @@ Lab Sections labs/lists/2d-lists labs/lists/references labs/objects/objects + labs/testing/unittest-objects labs/objects/data-structures diff --git a/site/labs/objects/data-structures.rst b/site/labs/objects/data-structures.rst index 9c414ed3..ba43ea3f 100644 --- a/site/labs/objects/data-structures.rst +++ b/site/labs/objects/data-structures.rst @@ -30,13 +30,7 @@ Pre Lab Exercises Before Kattis ============= -#. Add to the ``Person`` class from the previous lab - - * A reasonable ``__repr__`` method --- you can decide what the string looks like - * A reasonable ``__eq__`` method --- you can decide what it means for two ``Person`` objects to be equivalent - * Make instances of the class and write ``assert`` tests to verify correctness - - +#. Have a complete ``Person`` class from the previous lab #. Write a ``Contacts`` class that will manage a collection of ``Person`` objects * The class will keep track of many instances of ``Person`` objects @@ -60,6 +54,14 @@ Before Kattis * Make an instance of the class, add/remove ``Person`` objects to it, and write ``assert`` tests to verify correctness +#. Create unittest classes for the ``Contacts`` class + + * Write tests for each of the methods in each class + * You may find the ``Course`` class' :download:`unittests helpful <../../../test/test_course.py>` + * Run the tests with ``unittest.main(argv=[''], verbosity=2, exit=False)`` + * Ensure all tests pass + + Kattis Problems =============== diff --git a/site/labs/objects/objects.rst b/site/labs/objects/objects.rst index b3835ffa..f00fe4ed 100644 --- a/site/labs/objects/objects.rst +++ b/site/labs/objects/objects.rst @@ -52,29 +52,6 @@ Before Kattis * Make instances of the class and write ``assert`` tests to verify correctness -#. Create a ``Person`` class - - * Attribute for ``first_name`` - * Attribute for ``last_name`` - * Attribute for ``email_address`` - * The constructor will take three parameters for specifying the values of the attributes - * A method returning a string of their ``full_name()`` --- e.g. ``Bob Smith`` - * Make instances of the class and write ``assert`` tests to verify correctness - - -#. Create unittest classes for each of the above classes - - * Write tests for each of the methods in each class - * Be sure to reference the :doc:`unittest topic ` - * You may find the ``Circle`` class' :download:`unittests helpful <../../../test/test_circle.py>` - - * Be sure to remove the ``from src.circle import Circle`` line - - - * Run the tests with ``unittest.main(argv=[''], verbosity=2, exit=False)`` - * Ensure all tests pass - - Kattis Problems =============== diff --git a/site/labs/testing/unittest-objects.rst b/site/labs/testing/unittest-objects.rst new file mode 100644 index 00000000..20cf4da4 --- /dev/null +++ b/site/labs/testing/unittest-objects.rst @@ -0,0 +1,63 @@ +******************** +Unit Testing Objects +******************** + +* Feel free to use your laptop +* You are strongly encourage to work with others + + * When you get stuck, ask those sitting around you for help + * Get used to working together in the labs + * Peer teaching and peer learning has been empirically shown to be very effective + + + +Pre Lab Exercises +================= + +* Have the previous lab complete + + + +Before Kattis +============= + +#. Create a ``Person`` class + + * Attribute for ``first_name`` + * Attribute for ``last_name`` + * Attribute for ``email_address`` + * The constructor will take three parameters for specifying the values of the attributes + * A method returning a string of their ``full_name()`` --- e.g. ``Bob Smith`` + * Write a reasonable ``__eq__`` method --- you can decide what it means for two ``Person`` objects to be equivalent + * Write a reasonable ``__repr__`` method --- you can decide what the string looks like + * Make instances of the class and write ``assert`` tests to verify correctness + + +#. Create unittest classes for the ``Person`` class + + * Write tests for each of the methods in each class + * Be sure to reference the :doc:`unittest topic ` + * You may find the ``Circle`` class' :download:`unittests helpful <../../../test/test_circle.py>` + + * Be sure to remove the ``from src.circle import Circle`` line + + + * Run the tests with ``unittest.main(argv=[''], verbosity=2, exit=False)`` + * Ensure all tests pass + + + +Kattis Problems +=============== + +* You should be using a scrap piece of paper to work out the ideas for the following problems + + * The problems you are to solve are getting too complex to try to solve by just coding + * Trying to solve problems by just typing away will not yield success + + +#. https://open.kattis.com/problems/everywhere +#. https://open.kattis.com/problems/babelfish +#. https://open.kattis.com/problems/oddmanout +#. https://open.kattis.com/problems/securedoors +#. https://open.kattis.com/problems/modulo