Recall & Review
beginner
What is parametrize in pytest?
Parametrize allows you to run the same test function with different input values, making tests efficient and organized.
Click to reveal answer
intermediate
How can you conditionally parametrize tests in pytest?
You can use Python code or fixtures to decide which parameters to pass, so tests run only with relevant data.
Click to reveal answer
intermediate
Example of using
@pytest.mark.parametrize with a condition inside the test function.You parametrize all data but skip or assert only for certain conditions inside the test using
if statements.Click to reveal answer
beginner
Why use conditional parametrize instead of multiple test functions?
It keeps tests DRY (Don't Repeat Yourself), easier to maintain, and runs only needed cases based on conditions.
Click to reveal answer
intermediate
What is a simple way to skip certain parameter sets in pytest based on a condition?
Use
pytest.param with marks=pytest.mark.skipif(condition, reason='...') inside @pytest.mark.parametrize.Click to reveal answer
What does
@pytest.mark.parametrize do?✗ Incorrect
Parametrize runs the same test function with different sets of input values.
How can you skip a parameter set conditionally in pytest?
✗ Incorrect
Using pytest.param with skipif mark skips that parameter set based on the condition.
Why is conditional parametrize useful?
✗ Incorrect
Conditional parametrize helps run tests only for inputs that matter in the current context.
Which Python feature helps decide parameters dynamically in pytest?
✗ Incorrect
You can use if statements and functions to build parameter lists conditionally.
What happens if a test is skipped using
skipif in parametrize?✗ Incorrect
Tests marked with skipif are ignored and shown as skipped in reports.
Explain how to use conditional parametrize in pytest with an example.
Think about skipping some inputs based on a condition.
You got /4 concepts.
Why is conditional parametrize better than writing multiple test functions for different inputs?
Consider the DRY principle.
You got /4 concepts.