1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Testing in Python

Connected

Exercise

Conditional skipping

Sometimes, you want to skip a test if some condition is met. For example, you want to conduct a test unless today is Saturday. In this case, you can use the datetime library for getting the current day of the week and the pytest marker for conditional skipping the test function. To pass a condition to the conditional skipping pytest marker, you can use @pytest.mark.skipif(condition) The pytest library was already imported for you.

Instructions

100 XP
  • Add the "conditional skip" decorator to make it work.
  • Add the condition_string into the decorator call.
  • Complete the assertion tests.