0
0
PyTesttesting~10 mins

Running tests by marker (-m) in PyTest - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Aparametrize
Bfast
Cskip
Dslow
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.
2fill in blank
medium

Complete the command to run only tests marked as 'slow'.

PyTest
pytest -m [1]
Drag options to blanks, or click blank then click option'
Aslow
Bfast
Cskip
Dparametrize
Attempts:
3 left
💡 Hint
Common Mistakes
Using a marker name that does not exist in the tests.
Omitting the -m option.
3fill in blank
hard

Fix 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'
Aslow fast
Bslow and fast
Cslow or fast
Dslow | fast
Attempts:
3 left
💡 Hint
Common Mistakes
Using space without operator between markers.
Using 'and' instead of 'or' when wanting to run either marker.
4fill in blank
hard

Fill 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'
Aslow
Bfast
Cnetwork
Ddatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'or not' instead of 'and not'.
Not quoting the expression.
5fill in blank
hard

Fill 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'
Aslow
Bfast
Cnetwork
Ddatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting parentheses causing wrong operator precedence.
Using 'and' instead of 'or' inside parentheses.