CSE 163, Winter 2020: Homework 2: Part 2

Overview

In this part of the assignment, you will write tests for your solutions in Part 0 and Part 1.

Like in Homework 1, we have provided a function called assert_equals that takes an expected value and the value returned by your function, and compares them: if they don't match, the function will crash the program and tell you what was wrong. You can see more instructions an example for tests from the Homework 1 - Part 1 to see examples of how to call the tests.

One thing that is different from the last homework is the assert_equals lives in a file called cse163_utils.py. We imported the function in hw2_test.py in a special way so this shouldn't change how you call assert_equals. You should not modify anything in cse163_utils.py.

About paths on Ed

Recall that on HW1, you had to use this absolute path (e.g. /home/poem.txt) on Ed in your testing program. This has to do with how Ed runs your program when marking it (it only copies your Python files in to its testing directory). You will need to continue to do this for future assignments.

What this means is in your hw2_test.py, any place you specify a file name (e.g. poem.txt), you should use the absolute path on Ed instead (e.g. /home/poem.txt)

Grading

For full credit, your hw2_test.py must satisfy all of the following conditions:

  • Uses the main method pattern shown in class.
  • Has a function to test each of the functions in the hw2_manual.py and hw2_pandas.py that you were asked to write. It's okay to merge the test functions for the same problem in the different parts of the homework since their outputs are the same. There might be some redundancy in your tests which is expected since it's hard to factor out the different function calls and input types.
  • For each function you need to test, you should include a test that tests the example from the spec and one additional test that is different from what is shown in the spec. A single test is considered a call on assert_equals.
  • Each of these test functions should have a descriptive name that indicates which function is being tested (e.g. test_funky_sum)
  • Each of the test functions must be called from main.
  • Turn in any test CSV files you generate.