Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to skip the test with a reason.
PyTest
import pytest @pytest.mark.skip(reason=[1]) def test_example(): assert 1 == 1
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using True or False instead of a string as reason.
Leaving reason empty or None.
✗ Incorrect
The reason for skipping must be a string explaining why the test is skipped.
2fill in blank
mediumComplete the code to skip the test with a reason explaining it's broken.
PyTest
import pytest @pytest.mark.skip(reason=[1]) def test_broken_feature(): assert False
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean values instead of a string.
Not providing any reason.
✗ Incorrect
The skip reason should be a clear string message describing why the test is skipped.
3fill in blank
hardFix the error in the skip decorator by completing the reason argument correctly.
PyTest
import pytest @pytest.mark.skip(reason=[1]) def test_skip_fix(): assert True
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers or booleans instead of strings.
Omitting quotes around the reason.
✗ Incorrect
The reason must be a string, so use quotes around the message.
4fill in blank
hardFill both blanks to skip the test with a reason and add a simple assertion.
PyTest
import pytest @pytest.mark.skip(reason=[1]) def test_skip_and_assert(): assert [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using False in assertion which fails the test.
Using non-string for reason.
✗ Incorrect
The skip reason must be a string, and the assertion should be True to pass if run.
5fill in blank
hardFill all three blanks to skip the test with a reason, assert a condition, and add a print statement.
PyTest
import pytest @pytest.mark.skip(reason=[1]) def test_full_example(): assert [2] print([3])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using False in assertion causing failure.
Not using quotes for string values.
✗ Incorrect
The skip reason is a string, assertion is True to pass, and print outputs a string message.