1. 学习
  2. /
  3. 课程
  4. /
  5. Introduction to Testing in Python

Connected

练习

pytest.raises

In this exercise, you will continue writing the first test suite using the pytest library.

The function multiple_of_two checks whether the num is a multiple of 2 or not. In this exercise, you will implement a test that expects to raise an Exception.

The pytest package has been imported.

说明

100 XP
  • Define a context manager for the exception test.
  • Write a test to check that the zero input multiple_of_two(num=0) results in the ValueError exception.