0
0
PyTesttesting~10 mins

Coverage thresholds 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 run pytest with coverage and fail if coverage is below 80%.

PyTest
pytest --cov=my_package --cov-fail-under=[1]
Drag options to blanks, or click blank then click option'
A100
B70
C90
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using a value lower than 80 which allows lower coverage.
Using 100 which is too strict for many projects.
2fill in blank
medium

Complete the pytest command to measure coverage for the 'utils' module only.

PyTest
pytest --cov=[1] --cov-fail-under=75
Drag options to blanks, or click blank then click option'
Autils
Btests
Cmain
Dsetup
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tests' which measures test files, not source code.
Using 'setup' which is unrelated here.
3fill in blank
hard

Fix the error in the pytest coverage command to correctly fail if coverage is below 85%.

PyTest
pytest --cov=myapp --cov-fail-under=[1]
Drag options to blanks, or click blank then click option'
A85
B95
Cfail-under=85
D75
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'fail-under=85' as a value which is invalid.
Setting the threshold too low or too high.
4fill in blank
hard

Fill both blanks to create a pytest command that measures coverage for 'app' and fails if coverage is below 90%.

PyTest
pytest --cov=[1] --cov-fail-under=[2]
Drag options to blanks, or click blank then click option'
Aapp
B80
C90
Dtests
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tests' instead of 'app' for coverage.
Setting threshold to 80 instead of 90.
5fill in blank
hard

Fill all three blanks to create a pytest command that measures coverage for 'service', fails if coverage is below 85%, and outputs a coverage report in XML format.

PyTest
pytest --cov=[1] --cov-fail-under=[2] --cov-report=[3]
Drag options to blanks, or click blank then click option'
Aservice
B85
Cxml
Dhtml
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'html' instead of 'xml' for report format.
Setting threshold incorrectly.