Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start coverage measurement in a Flask app test.
Flask
import coverage cov = coverage.[1]() cov.start()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'coverage' instead of 'Coverage'
Calling 'start' instead of creating the coverage object
✗ Incorrect
The Coverage() class from the coverage module is used to create a coverage object.
2fill in blank
mediumComplete the code to stop coverage measurement and save the report.
Flask
cov.stop()
cov.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'report' instead of 'save' before generating the report
Calling 'start' again instead of saving
✗ Incorrect
After stopping coverage, save() writes the collected data to disk.
3fill in blank
hardFix the error in generating an HTML coverage report.
Flask
cov.[1](directory='coverage_html_report')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'html_reporter' or similar incorrect method names
Passing wrong argument names
✗ Incorrect
The correct method to generate an HTML report is html_report().
4fill in blank
hardFill both blanks to create a coverage report for specific files and omit tests.
Flask
cov = coverage.Coverage(source=[[1]], omit=[[2]])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'tests/*' as source instead of omit
Omitting the app folder instead of tests
✗ Incorrect
The source parameter specifies the app folder, and omit excludes test files.
5fill in blank
hardFill all three blanks to correctly configure coverage to start, stop, and save in a Flask test setup.
Flask
cov = coverage.[1](branch=True) cov.[2]() # run tests cov.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling 'save()' before stopping coverage
Not creating the coverage object properly
✗ Incorrect
Create a coverage object with Coverage(), then start() before tests, and stop() after tests.