Instructions for weatherTesting

(produced at 11:48 a.m. UTC on 2022-11-11)

This task is part of project08 which is due at 23:00 EST on 2022-11-16.

You have the option to work with a partner on this task if you wish. Working with a partner requires more work to coordinate schedules, but if you work together and make sure that you are both understanding the code you write, you will make progress faster and learn more.

You can download the starter code for this task using this link.

You can submit this task using this link.

Put all of your work for this task into the file test_weather.py
(which is provided among the starter files)

Overview

In this task, you will practice writing test cases with optimism by writing test cases to catch four incorrect implementations of a project for which we've already given you the solution file. You are not required to write any functions for this project, you only need to write test cases for provided functions.

We have given you a file called weather.py which represents a correct solution to a fictional project task. It defines 3 functions: listFrostMonths, tempsStartingFrom, and rainOrShine. We have also given you the files weather1.py, weather2.py, weather3.py, and weather4.py, each of which defines some of the three functions correctly but gets at least one wrong in some way. Your job is to write [at least 9 test cases](#goal:core.check:call-case) (more if you like) such that:

  1. All of your test cases pass when run on the correct solution file.
  2. At least one of your test cases fails for each of the four incorrect files (it can be a different test case each time).

In other words: your test cases need to catch the incorrect files but let the correct file through.

Approach

You should read the docstrings provided in weather.py to understand what each function is supposed to do. Feel free to read the code as well, and also use the shell to play around with them a bit to understand how they are supposed to work. We have purposefully omitted any examples of how they are supposed to behave, because coming up with those examples is your job here.

You will write your test cases in the test_weather.py file (which is also the file you'll ultimately submit). We have already provided the code that sets up one tester for each function, and at the top of the file, there is a block of code that looks like this:

# TODO: Uncomment one of these lines at a time to select which file your
# tests are run on. These lines all rename the imported module to
# 'weather' so that you can write your tests using 'weather' as the
# target.
import weather
#import weather1 as weather
#import weather2 as weather
#import weather3 as weather
#import weather4 as weather

As it instructs, you can uncomment one of those lines and comment out whichever one you had been using before to switch which of the five supplied files your tests are run on. Just remember that when you submit your file, the first import of just the weather module must be uncommented so that we can properly test your code.

You should first focus on defining a few tests for each function that will pass when run against the correct submission. If you're lucky, that will be enough to catch all the incorrect submissions. If not, you should try the following:

  1. Read the docstrings and look for any notes about unusual behavior in certain cases. Are you testing those cases? Also try to think of implied special cases.
  2. You can try reading the code of the incorrect files and comparing it to the correct file. In each file, some of the changed functions are still correct, and some are wrong, however, so just because a function is written differently does not mean that there will definitely be an error in it.

When you've defined enough test cases that all of the incorrect files fail at least one test, you are done.

Notes

  1. You are not writing any functions for this task, so you are not required to write any docstrings.
  2. Remember that to define a test case, first use the case method of a tester object and store the result in a variable, giving case the same arguments you'd normally give to the function being tested. Then, use the checkReturnValue method of that case object to check the result. The whole process looks like this:

    tester = testFunction(max)
    case = tester.case(3, 4)
    case.checkReturnValue(4)
    

Examples

Rubric

Group goals:
 
unknown Your tests must all pass for the correct solution
We will run your tests on the correct solution file weather.py and ensure that all of your tests pass.
 
unknown At least one of your tests must fail for the incorrect file weather1.py
We will run your tests on the incorrect file {mname}.py and ensure that at least one of your tests fails (i.e., it catches an error in this incorrect file).
 
unknown At least one of your tests must fail for the incorrect file weather2.py
We will run your tests on the incorrect file {mname}.py and ensure that at least one of your tests fails (i.e., it catches an error in this incorrect file).
 
unknown At least one of your tests must fail for the incorrect file weather3.py
We will run your tests on the incorrect file {mname}.py and ensure that at least one of your tests fails (i.e., it catches an error in this incorrect file).
 
unknown At least one of your tests must fail for the incorrect file weather4.py
We will run your tests on the incorrect file {mname}.py and ensure that at least one of your tests fails (i.e., it catches an error in this incorrect file).
 
unknown Import the weather module
We will check to make sure that you import the weather module.
 
unknown Call case
Call case in at least 9 places.
 
unknown Call checkReturnValue
Call checkReturnValue in at least 9 places.