UNB/ CS/ David Bremner/ teaching/ cs2613/ labs/ CS2613 Lab 15

Background

A first example

Time
15 min
Activity
Small groups

Pytest

Time
20 min
Activity
Small groups

In this part of the course we will be using pytest to write unit tests.

Modules

Time
20 min
Activity
Small groups

More testing, docstrings

Time
15 min
Activity
Small groups

Indentation

Time
20 min
Activity
Small groups
    for i in range(1,101):
    if (i%3 == 0 and i%5 == 0):
    print("FizzBuzz")
    elif (i%3==0):
    print("Buzz")
    else:
    print(i)

Exceptions

Time
20 min
Activity
Small groups
    def fraction(a,b):
        return a/b;
    from divisive import fraction

    def test_fraction_int():
        assert fraction(4,2) == 2;

    def test_fraction_NaN():
        assert fraction(4,0) == 'NaN';