PyCharm 2017.1 Help

Configuring Code Coverage Measurement

PyCharm makes it possible to configure the various aspects of code coverage measurement. In this section:

To configure code coverage behavior

  1. Open the Settings/Preferences dialog box, and then click Coverage under Build, Execution, Deployment. The Coverage page opens.
  2. Define how the collected coverage data will be processed:
    • To have the Code Coverage dialog box shown every time you launch a new run configuration with code coverage, choose Show options before applying coverage to the editor.
    • To discard the new code coverage results, choose Do not apply collected coverage.
    • To discard the active suites and use the new one every time you launch a new run configuration with code coverage, choose Replace active suites with the new one.
    • To have the new code coverage suite appended to the active suites every time you launch a new run configuration with code coverage, choose Add to active suites.
  3. Define the behaviour of the Coverage tool window when an application or test is run with coverage:
    • To have the Coverage tool window opened automatically, select the Activate Coverage View check box.
    • To open the Coverage tool window manually, clear the Activate Coverage View check box.
  4. Select the check box to specify which of the coverage tools you want to use - the one bundled with PyCharm, or included in the active Python interpreter.
  5. Select the check box to specify whether you want to use the branch coverage. Thus additional information to the pure line coverage reports is added, marking the coverage of lines with conditional statements as incomplete in case one or more branches haven’t been executed:
    /help/img/idea/2017.1/py_branch_coverage.png

To configure code coverage colors

  1. Open the Colors and Fonts page of the editor settings.

    Alternatively, just click /help/img/idea/2017.1/settingsCoverage.png in the statistics pop-up.

  2. Expand Colors and Fonts node, and select General.
  3. In the list of textual components, select the required type of coverage, for example, Full, Partial or Uncovered, and then choose the desired colors:
    /help/img/idea/2017.1/coverageColors.png

See Also

Last modified: 26 July 2017