In this class, you will complete a daily Program of the Day (POTD) assignment to build your coding skills. These short programs are graded using automated tests. This means that we provide another program that runs your program and checks whether its behavior is correct. You’re provided with the test program so that you can check your work, and you will know when you have arrived at a correct and working solution to the POTD.
This guide walks you through:
The prompt for each POTD is linked from the Schedule table on the course webpage; these are labeled P##, where ## is the number of the lecture when the program is assigned. The program is due at the start of the following class (not counting exam or practicum days).
As an example, here’s the link to the first POTD prompt: P01. Throughout this document, we’ll use P01 as a running example, but the process applies for all POTDs.
You can find the skeleton code and test program for each POTD at this url:
https://github.com/csci141/POTD/tree/2540_wehrwein/skel.
This link can also be found in the Quick Links section (just above
the Schedule section) of the course webpage. On this page, you’ll see a
list of files. All the files that pertain to P01 have filenames with the
prefix P01_
. Usually, you’ll find a skeleton file
(P01_quiz1.py
) and a test program
(P01_quiz1_test.py
).
To download the files, click on the file you’d like to download;
you’ll see a preview of the file in a pane. At the top right, click the
“Download raw file” button to download
the file to your computer.
Download the skeleton, test program, and any others with the corresponding prefix, to the lab computer or personal computer you’re working on. It’s strongly recommended to you set up a folder to hold all your code for this class, and I would recommend having a subfolder for all the POTDs. Move the files from your downloads folder (or wherever they landed) into your CSCI 141 folder.
iotest.py
The test programs for POTD 01–09 rely on a separate module called
iotest
. You will need to download iotest.py
(also found at the URL above). Download this file and save it to your
POTD folder.
pytest
You may need to install the pytest
package, which our
test code relies on. In Thonny:
Download P00_setup_test.py
and run it in Thonny. If you
have completed the above steps, the program should produce the following
output:
iotest found
pytest found
Otherwise, you’ll see an error message telling you which step failed.
Make sure that both files (P01_quiz1.py
and
P01_quiz1_test.py
) are in the same directory, and that
there are no other python files in this directory. If they are not in
the same folder or other python files are present in that folder, the
test program will may run correctly.
Open the test program (P01_quiz1_test.py
) in Thonny and
press the friendly green run button to run the tests on your
solution.
If you haven’t completed Program 1 yet, you’ll see the following output:
--- Starting Test Runner ---
[FAIL] ❌ Arguments: (with stdin: [''])
Differences:
+
- What is 4 * 6 ?
- 4 * 6 is 24
----------------------------
Total: 0 / 1 Tests Passed
----------------------------
In this case, there is only one test case. The test program expects
to see the lines next to the -
(displayed in red in Thonny)
but your program produced the text next to the + (displayed in green in
Thonny); in this case, we haven’t written any code so our program
produces no output.
Once your program passes the tests, you’ll see an output like this:
--- Starting Test Runner ---
[PASS] ✅ Arguments: (with stdin: [''])
----------------------------
Total: 1 / 1 Tests Passed
----------------------------
All tests passed - nice work! 🎉