Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to mark the test with the label 'slow'.
PyTest
import pytest @pytest.mark.[1] def test_example(): assert 1 + 1 == 2
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fast' or 'skip' instead of 'slow' as the marker name.
Forgetting to add @pytest.mark before the marker.
✗ Incorrect
The marker 'slow' is used to label tests that take longer to run. Here, @pytest.mark.slow marks the test accordingly.
2fill in blank
mediumComplete the command to run only tests marked as 'slow'.
PyTest
pytest -m [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a marker name that does not exist in the tests.
Omitting the -m option.
✗ Incorrect
The command 'pytest -m slow' runs only tests marked with the 'slow' marker.
3fill in blank
hardFix the error in the command to run tests marked 'slow' or 'fast'.
PyTest
pytest -m "[1]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using space without operator between markers.
Using 'and' instead of 'or' when wanting to run either marker.
✗ Incorrect
To run tests marked 'slow' or 'fast', use 'pytest -m "slow or fast"' or 'pytest -m "slow | fast"'. The pipe '|' and 'or' are correct operators for OR in marker expressions.
4fill in blank
hardFill both blanks to run tests marked 'slow' but not 'network'.
PyTest
pytest -m "[1] and not [2]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'or not' instead of 'and not'.
Not quoting the expression.
✗ Incorrect
The command 'pytest -m "slow and not network"' runs tests marked 'slow' but excludes those also marked 'network'.
5fill in blank
hardFill all three blanks to run tests marked 'slow' or 'fast' but not 'network'.
PyTest
pytest -m "([1] or [2]) and not [3]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses causing wrong operator precedence.
Using 'and' instead of 'or' inside parentheses.
✗ Incorrect
The command 'pytest -m "(slow or fast) and not network"' runs tests marked 'slow' or 'fast' but excludes those marked 'network'.