Pytest: Use `collections.Counter` instead of a `dict` in `terminal.py`

Created on 7 Oct 2020  路  3Comments  路  Source: pytest-dev/pytest

Consider the following code defining counts, and the similar counts_by_filename below:

https://github.com/pytest-dev/pytest/blob/95917f8833bc71229c3ac4fb73cbf5ca5818201b/src/_pytest/terminal.py#L757-L760

This is a classic case for collections.Counter, and would make a great first pull request!

Example solution initialising the Counter from an iterable:

counts = Counter(... for item in items)  # you fill in the ... part
easy refactoring

Most helpful comment

Great! Will do. Thanks!

All 3 comments

Hello! I'm new to the open source community. Is this something I can pick up and work on?

Absolutely! @-mention me from the PR and I'll be happy to review it for you :smiley:

Great! Will do. Thanks!

Was this page helpful?
0 / 5 - 0 ratings