0
0
PyTesttesting~10 mins

Why coverage measures test completeness in PyTest - Test Your Understanding

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

Complete the code to import the coverage module.

PyTest
import [1]
Drag options to blanks, or click blank then click option'
Acoverage
Bunittest
Cpytest
Dsys
Attempts:
3 left
💡 Hint
Common Mistakes
Importing pytest instead of coverage
Using unittest which is for testing but not coverage
2fill in blank
medium

Complete the code to start coverage measurement before tests.

PyTest
cov = coverage.Coverage()
cov.[1]()
Drag options to blanks, or click blank then click option'
Astop
Bstart
Crun
Dreport
Attempts:
3 left
💡 Hint
Common Mistakes
Calling stop() before tests
Using report() which is for showing results
3fill in blank
hard

Fix the error in the code to stop coverage after tests.

PyTest
cov.[1]()
Drag options to blanks, or click blank then click option'
Aend
Bstart
Cbegin
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Calling start() again
Using non-existent methods like begin or end
4fill in blank
hard

Fill both blanks to generate and save the coverage report.

PyTest
cov.[1]()
cov.[2]()
Drag options to blanks, or click blank then click option'
Areport
Bsave
Cstart
Dstop
Attempts:
3 left
💡 Hint
Common Mistakes
Calling start or stop instead of report or save
Reversing the order of methods
5fill in blank
hard

Fill all three blanks to run tests with coverage and print the report.

PyTest
cov = coverage.Coverage()
cov.[1]()
# run tests here
cov.[2]()
cov.[3]()
Drag options to blanks, or click blank then click option'
Astart
Bstop
Creport
Dsave
Attempts:
3 left
💡 Hint
Common Mistakes
Using save instead of report at the end
Stopping coverage before tests