Merge pull request #405 from cjmayo/tidyten13

Remove encoding of TestLogger diff  and url in Checker.check_url_data()
This commit is contained in:
anarcat 2020-05-21 08:56:08 -04:00 committed by GitHub
commit a226b4e406
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 17 deletions

View file

@ -103,7 +103,7 @@ class Checker(task.LoggedCheckedTask):
self.check_url_data(url_data)
finally:
self.urlqueue.task_done(url_data)
self.setName(self.origname)
self.name = self.origname
except urlqueue.Empty:
pass
except Exception:
@ -111,9 +111,5 @@ class Checker(task.LoggedCheckedTask):
def check_url_data(self, url_data):
"""Check one URL data instance."""
if url_data.url is None:
url = ""
else:
url = url_data.url.encode("ascii", "replace")
self.setName("CheckThread-%s" % url)
self.name = "CheckThread-%s" % (url_data.url or "")
check_url(url_data, self.logger)

View file

@ -37,7 +37,7 @@ class Interrupt(task.CheckedTask):
def run_checked(self):
"""Wait and raise KeyboardInterrupt after."""
self.start_time = time.time()
self.setName("Interrupt")
self.name = "Interrupt"
while not self.stopped(self.WaitSeconds):
duration = time.time() - self.start_time
if duration > self.duration:

View file

@ -39,7 +39,7 @@ class Status(task.LoggedCheckedTask):
def run_checked(self):
"""Print periodic status messages."""
self.start_time = time.time()
self.setName("Status")
self.name = "Status"
# the first status should be after a second
wait_seconds = 1
first_wait = True

View file

@ -26,7 +26,6 @@ import linkcheck.configuration
import linkcheck.director
import linkcheck.logger
from .. import get_file
from builtins import str as str_text
# helper alias
get_url_from = linkcheck.checker.get_url_from
@ -137,14 +136,10 @@ class TestLogger(linkcheck.logger._Logger):
"""
self.expected = self.normalize(self.expected)
self.result = self.normalize(self.result)
for line in difflib.unified_diff(self.expected, self.result,
fromfile="expected", tofile="result",
lineterm=""):
if not isinstance(line, str_text):
# The ---, +++ and @@ lines from diff format are ascii encoded.
# Make them unicode.
line = str_text(line, "ascii", "replace")
self.diff.append(line)
self.diff = list(difflib.unified_diff(self.expected, self.result,
fromfile="expected",
tofile="result",
lineterm=""))
def get_file_url(filename):