0
0
PyTesttesting~10 mins

Coverage in CI pipelines 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 reporting.

PyTest
pytest --cov=[1] tests/
Drag options to blanks, or click blank then click option'
Amy_module
Btests
Csetup.py
Ddocs
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tests' as the coverage target instead of the main module.
2fill in blank
medium

Complete the pytest command to generate a coverage report in XML format for CI tools.

PyTest
pytest --cov=my_module --cov-report=[1] tests/
Drag options to blanks, or click blank then click option'
Aterm
Bhtml
Cxml
Dannotate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'html' instead of 'xml' for CI coverage reports.
3fill in blank
hard

Fix the error in the pytest coverage command to include branch coverage.

PyTest
pytest --cov=my_module --cov-report=xml --cov-branch=[1] tests/
Drag options to blanks, or click blank then click option'
Atrue
Byes
C1
Don
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'yes' or 'on' which are not recognized by pytest-cov.
4fill in blank
hard

Fill both blanks to configure pytest coverage to fail if coverage is below 80% and to show the report in the terminal.

PyTest
pytest --cov=my_module --cov-fail-under=[1] --cov-report=[2] tests/
Drag options to blanks, or click blank then click option'
A80
Bterm
Chtml
D70
Attempts:
3 left
💡 Hint
Common Mistakes
Setting fail-under too low or using 'html' instead of 'term' for terminal output.
5fill in blank
hard

Fill all four blanks to create a pytest coverage command that measures coverage, generates XML and HTML reports, and fails if coverage is below 90%.

PyTest
pytest --cov=[1] --cov-report=[2] --cov-report=[3] --cov-fail-under=[4] tests/
Drag options to blanks, or click blank then click option'
Amy_module
Bxml
Chtml
D90
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to specify the module or mixing up report formats.