MulaiMulai sekarang secara gratis

The first test suite

In this exercise, you will write the first test suite that includes the types of tests that you have learned using the pytest library.

The function multiple_of_two checks whether the num is a multiple of 2 or not. You will implement and run two regular assert tests.

The pytest package has already been imported.

Latihan ini adalah bagian dari kursus

Introduction to Testing in Python

Lihat Kursus

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

def multiple_of_two(num):
    if num == 0:
        raise(ValueError)
    return num % 2 == 0

def test_numbers():
    # Write the "True" test below
    ____ multiple_of_two(____) ____ ____
Edit dan Jalankan Kode