From edb49c652c423143165e1378a0151c913400d331 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Thu, 8 Mar 2018 12:56:36 +0100 Subject: [PATCH] Fix test failures with newer flake8 and pylint. Closes: #891721 Signed-off-by: Mattia Rizzolo --- debian/changelog | 7 +++++++ ubuntutools/requestsync/mail.py | 2 +- ubuntutools/sponsor_patch/patch.py | 2 +- ubuntutools/test/test_config.py | 2 +- ubuntutools/test/test_logger.py | 2 +- ubuntutools/test/test_pylint.py | 13 +++++++------ 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index b2f9c31..79387f1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +ubuntu-dev-tools (0.162) UNRELEASED; urgency=medium + + * Team upload. + * Fix test failures with newer flake8 and pylint. Closes: #891721 + + -- Mattia Rizzolo Thu, 08 Mar 2018 12:35:24 +0100 + ubuntu-dev-tools (0.161) unstable; urgency=medium * Team upload. diff --git a/ubuntutools/requestsync/mail.py b/ubuntutools/requestsync/mail.py index e3388f2..9170195 100644 --- a/ubuntutools/requestsync/mail.py +++ b/ubuntutools/requestsync/mail.py @@ -232,7 +232,7 @@ Content-Type: text/plain; charset=UTF-8 'invalid username and password.') s.quit() return - except: + except smtplib.SMTPException: Logger.error('Unknown SMTP error.') s.quit() return diff --git a/ubuntutools/sponsor_patch/patch.py b/ubuntutools/sponsor_patch/patch.py index bde0052..cd99672 100644 --- a/ubuntutools/sponsor_patch/patch.py +++ b/ubuntutools/sponsor_patch/patch.py @@ -73,7 +73,7 @@ class Patch(object): cmd = ["diffstat", "-l", "-p0", self._full_path] process = subprocess.Popen(cmd, stdout=subprocess.PIPE) changed_files = process.communicate()[0] - self._changed_files = [l for l in changed_files.split("\n") if l != ""] + self._changed_files = [f for f in changed_files.split("\n") if f != ""] def get_strip_level(self): """Returns the stript level for the patch.""" diff --git a/ubuntutools/test/test_config.py b/ubuntutools/test/test_config.py index 2b0af8e..d78dcee 100644 --- a/ubuntutools/test/test_config.py +++ b/ubuntutools/test/test_config.py @@ -20,7 +20,7 @@ import sys import locale try: from StringIO import StringIO -except: +except ImportError: from io import StringIO import mock diff --git a/ubuntutools/test/test_logger.py b/ubuntutools/test/test_logger.py index 36b0a72..6593646 100644 --- a/ubuntutools/test/test_logger.py +++ b/ubuntutools/test/test_logger.py @@ -16,7 +16,7 @@ try: from StringIO import StringIO -except: +except ImportError: from io import StringIO import sys diff --git a/ubuntutools/test/test_pylint.py b/ubuntutools/test/test_pylint.py index 9b939ba..4684fd3 100644 --- a/ubuntutools/test/test_pylint.py +++ b/ubuntutools/test/test_pylint.py @@ -40,9 +40,10 @@ class PylintTestCase(unittest.TestCase): cmd = [pylint_binary, '--rcfile=ubuntutools/test/pylint.conf', '-E', '--reports=n', '--confidence=HIGH', '--'] + files sys.stderr.write("Running following command:\n{}\n".format(" ".join(cmd))) - process = subprocess.Popen(cmd, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, close_fds=True) - - out, err = process.communicate() - self.assertFalse(err, pylint_binary + ' crashed. Error output:\n' + err.decode()) - self.assertFalse(out, pylint_binary + " found issues:\n" + out.decode()) + try: + subprocess.check_output(cmd, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + self.fail( + '%s crashed (%d). Error output:\n%s' % + (pylint_binary, e.returncode, e.output.decode()) + )