question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose Coverage's --sort as --cov-sort pytest option

See original GitHub issue

Summary

A useful feature of Coverage is to sort the report by the reported metrics (docs), rather than just by filename. Especially in legacy or unfamiliar code, sorting by branch or cover helps in trying to understand the areas of risk. It would be helpful to expose this option as one of the flags pytest-cov can pass along to Coverage here.

In a tox project using setup.cfg, for example, the only alternative (I know of) is to set the sorting in the Coverage section, but this imposes a particular sorting and isn’t as easy to change quickly, and might become a source of accidental diffs when left changed.

I’d be happy to open a pull request to this effect, but wanted to start with some discussion first 😄

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:5
  • Comments:7

github_iconTop GitHub Comments

1reaction
nedbatcommented, Mar 23, 2022

Another option is to simply use the coverage report command instead of having pytest-cov do the reporting. There’s no need for the reporting to happen in the pytest plugin.

0reactions
daneahcommented, Mar 24, 2022

@nedbat Maybe I didn’t explain super well; I like to have coverage run as part of just running tox, and could do that with two sequential commands, but ad hoc I like to change the sorting for a better view of things, and don’t like to fiddle with setup.cfg to do it. This is purely a convenience request. I could also really be missing something 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reporting — pytest-cov 4.0.0 documentation - Read the Docs
It is possible to generate any combination of the reports for a single test run. The available reports are terminal (with or without...
Read more >
pytest - Python click sample code test case does not give 100 ...
The code works correctly. $ export PYTHONPATH=. $ python commands/cmd.py Usage: cmd.py [OPTIONS] COMMAND [ARGS]... Options ...
Read more >
PyCharm - Run/Debug Configuration: pytest - JetBrains
The plugin coverage for pytest, due to technical restrictions, breaks PyCharm's ... Options. Publish all ports: Expose all container ports to the host....
Read more >
Effective Python Testing With Pytest
Most functional tests follow the Arrange-Act-Assert model: Arrange, or set up, the conditions for the test; Act by calling some function or ...
Read more >
testmon: About
pytest -testmon is a pytest plugin which executes only tests you need to run. It collects dependencies between tests and executed code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found