Merge pull request #7874 from tanvimehta/master

This commit is contained in:
Zac Hatfield-Dodds 2020-10-08 17:36:54 +11:00 committed by GitHub
commit dbd082af96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 8 deletions

View File

@ -275,6 +275,7 @@ Sven-Hendrik Haase
Sylvain Marié Sylvain Marié
Tadek Teleżyński Tadek Teleżyński
Takafumi Arakaki Takafumi Arakaki
Tanvi Mehta
Tarcisio Fischer Tarcisio Fischer
Tareq Alayan Tareq Alayan
Ted Xiao Ted Xiao

View File

@ -8,6 +8,7 @@ import inspect
import platform import platform
import sys import sys
import warnings import warnings
from collections import Counter
from functools import partial from functools import partial
from pathlib import Path from pathlib import Path
from typing import Any from typing import Any
@ -754,10 +755,7 @@ class TerminalReporter:
# because later versions are going to get rid of them anyway. # because later versions are going to get rid of them anyway.
if self.config.option.verbose < 0: if self.config.option.verbose < 0:
if self.config.option.verbose < -1: if self.config.option.verbose < -1:
counts: Dict[str, int] = {} counts = Counter(item.nodeid.split("::", 1)[0] for item in items)
for item in items:
name = item.nodeid.split("::", 1)[0]
counts[name] = counts.get(name, 0) + 1
for name, count in sorted(counts.items()): for name, count in sorted(counts.items()):
self._tw.line("%s: %d" % (name, count)) self._tw.line("%s: %d" % (name, count))
else: else:
@ -922,10 +920,9 @@ class TerminalReporter:
if len(locations) < 10: if len(locations) < 10:
return "\n".join(map(str, locations)) return "\n".join(map(str, locations))
counts_by_filename: Dict[str, int] = {} counts_by_filename = Counter(
for loc in locations: str(loc).split("::", 1)[0] for loc in locations
key = str(loc).split("::", 1)[0] )
counts_by_filename[key] = counts_by_filename.get(key, 0) + 1
return "\n".join( return "\n".join(
"{}: {} warning{}".format(k, v, "s" if v > 1 else "") "{}: {} warning{}".format(k, v, "s" if v > 1 else "")
for k, v in counts_by_filename.items() for k, v in counts_by_filename.items()