Skip to content

Commit

Permalink
Merge pull request pytest-dev#7874 from tanvimehta/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Oct 8, 2020
2 parents 5acc55e + d093931 commit dbd082a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ Sven-Hendrik Haase
Sylvain Marié
Tadek Teleżyński
Takafumi Arakaki
Tanvi Mehta
Tarcisio Fischer
Tareq Alayan
Ted Xiao
Expand Down
13 changes: 5 additions & 8 deletions src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import platform
import sys
import warnings
from collections import Counter
from functools import partial
from pathlib import Path
from typing import Any
Expand Down Expand Up @@ -754,10 +755,7 @@ def _printcollecteditems(self, items: Sequence[Item]) -> None:
# because later versions are going to get rid of them anyway.
if self.config.option.verbose < 0:
if self.config.option.verbose < -1:
counts: Dict[str, int] = {}
for item in items:
name = item.nodeid.split("::", 1)[0]
counts[name] = counts.get(name, 0) + 1
counts = Counter(item.nodeid.split("::", 1)[0] for item in items)
for name, count in sorted(counts.items()):
self._tw.line("%s: %d" % (name, count))
else:
Expand Down Expand Up @@ -922,10 +920,9 @@ def collapsed_location_report(reports: List[WarningReport]) -> str:
if len(locations) < 10:
return "\n".join(map(str, locations))

counts_by_filename: Dict[str, int] = {}
for loc in locations:
key = str(loc).split("::", 1)[0]
counts_by_filename[key] = counts_by_filename.get(key, 0) + 1
counts_by_filename = Counter(
str(loc).split("::", 1)[0] for loc in locations
)
return "\n".join(
"{}: {} warning{}".format(k, v, "s" if v > 1 else "")
for k, v in counts_by_filename.items()
Expand Down

0 comments on commit dbd082a

Please sign in to comment.