mirror of
https://github.com/progval/irctest.git
synced 2025-04-07 15:59:49 +00:00
rmeove dead code
This commit is contained in:
@ -44,21 +44,3 @@ class MultipleReplacer:
|
|||||||
|
|
||||||
def __call__(self, s: str) -> str:
|
def __call__(self, s: str) -> str:
|
||||||
return self._matcher.sub(lambda m: self._dict[m.group(0)], s)
|
return self._matcher.sub(lambda m: self._dict[m.group(0)], s)
|
||||||
|
|
||||||
|
|
||||||
def normalizeWhitespace(s: str, removeNewline: bool = True) -> str:
|
|
||||||
r"""Normalizes the whitespace in a string; \s+ becomes one space."""
|
|
||||||
if not s:
|
|
||||||
return str(s) # not the same reference
|
|
||||||
starts_with_space = s[0] in " \n\t\r"
|
|
||||||
ends_with_space = s[-1] in " \n\t\r"
|
|
||||||
if removeNewline:
|
|
||||||
newline_re = re.compile("[\r\n]+")
|
|
||||||
s = " ".join(filter(bool, newline_re.split(s)))
|
|
||||||
s = " ".join(filter(bool, s.split("\t")))
|
|
||||||
s = " ".join(filter(bool, s.split(" ")))
|
|
||||||
if starts_with_space:
|
|
||||||
s = " " + s
|
|
||||||
if ends_with_space:
|
|
||||||
s += " "
|
|
||||||
return s
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import collections
|
|
||||||
from typing import Dict, Union
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
@ -54,38 +52,3 @@ class NotRequiredBySpecifications(unittest.SkipTest):
|
|||||||
class SkipStrictTest(unittest.SkipTest):
|
class SkipStrictTest(unittest.SkipTest):
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
return "Tests not required because strict tests are disabled."
|
return "Tests not required because strict tests are disabled."
|
||||||
|
|
||||||
|
|
||||||
class TextTestResult(unittest.TextTestResult):
|
|
||||||
def getDescription(self, test: unittest.TestCase) -> str:
|
|
||||||
if hasattr(test, "description"):
|
|
||||||
doc_first_lines = test.description() # type: ignore
|
|
||||||
else:
|
|
||||||
doc_first_lines = test.shortDescription()
|
|
||||||
return "\n".join((str(test), doc_first_lines or ""))
|
|
||||||
|
|
||||||
|
|
||||||
class TextTestRunner(unittest.TextTestRunner):
|
|
||||||
"""Small wrapper around unittest.TextTestRunner that reports the
|
|
||||||
number of tests that were skipped because the software does not support
|
|
||||||
an optional feature."""
|
|
||||||
|
|
||||||
resultclass = TextTestResult
|
|
||||||
|
|
||||||
def run(
|
|
||||||
self, test: Union[unittest.TestSuite, unittest.TestCase]
|
|
||||||
) -> unittest.TestResult:
|
|
||||||
result = super().run(test)
|
|
||||||
assert self.resultclass is TextTestResult
|
|
||||||
if result.skipped:
|
|
||||||
print()
|
|
||||||
print(
|
|
||||||
"Some tests were skipped because the following optional "
|
|
||||||
"specifications/mechanisms are not supported:"
|
|
||||||
)
|
|
||||||
msg_to_count: Dict[str, int] = collections.defaultdict(lambda: 0)
|
|
||||||
for (test, msg) in result.skipped:
|
|
||||||
msg_to_count[msg] += 1
|
|
||||||
for (msg, count) in sorted(msg_to_count.items()):
|
|
||||||
print("\t{} ({} test(s))".format(msg, count))
|
|
||||||
return result
|
|
||||||
|
Reference in New Issue
Block a user