UNB/ CS/ David Bremner/ teaching/ cs2613/ labs/ Lab 14

Before the Lab


A first example

Time
15 min
Activity
individual

Pytest

Time
20 min
Activity
individual

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

Modules

Time
20 min
Activity
individual

More testing, docstrings

Time
15 min
Activity
individual

Indentation

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

Exceptions

Time
20 min
Activity
individual
    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';