From d1c163401153329363a010373cb512f8e59ef1e2 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 9 Sep 2016 10:41:19 +0200 Subject: pep8/pyflakes cleanups --- examples/wrap_cl.py | 1 + examples/zeitgeist-git.py | 27 +++++++++--------- gbp/command_wrappers.py | 1 - gbp/deb/__init__.py | 9 +++--- gbp/deb/changelog.py | 14 +++++---- gbp/deb/control.py | 3 ++ gbp/deb/dscfile.py | 12 ++++---- gbp/deb/format.py | 5 ++-- gbp/deb/pristinetar.py | 2 +- gbp/deb/source.py | 7 +++-- gbp/deb/uscan.py | 15 ++++++---- gbp/git/__init__.py | 15 +++++----- gbp/git/args.py | 2 +- gbp/git/commit.py | 3 -- gbp/git/errors.py | 2 +- gbp/git/fastimport.py | 5 ++-- gbp/git/modifier.py | 14 +++++---- gbp/git/vfs.py | 3 +- gbp/log.py | 11 ++++++-- gbp/pkg/pristinetar.py | 4 +-- gbp/rpm/git.py | 1 - gbp/rpm/lib_rpm.py | 5 ++-- gbp/scripts/common/buildpackage.py | 9 +++--- gbp/scripts/common/import_orig.py | 1 + gbp/scripts/common/pq.py | 14 ++++----- gbp/scripts/config.py | 2 +- gbp/scripts/create_remote_repo.py | 16 ++++++----- gbp/scripts/import_dscs.py | 11 +++++--- gbp/scripts/import_orig.py | 2 +- gbp/scripts/pq.py | 44 ++++++++++++++++------------- gbp/scripts/pq_rpm.py | 8 +++--- gbp/scripts/supercommand.py | 13 +++++---- gbp/tristate.py | 13 +++++---- requirements.txt | 1 + setup.cfg | 4 ++- setup.py | 2 +- tests/01_test_help.py | 2 +- tests/02_test_upstream_source_tar_unpack.py | 17 +++++------ tests/03_test_dch_guess_version.py | 4 +-- tests/04_test_submodules.py | 25 ++++++++++------ tests/05_test_detection.py | 2 ++ tests/06_test_upstream_source.py | 3 +- tests/11_test_dch_main.py | 36 +++-------------------- tests/23_test_dch_extract_bts_cmds.py | 1 - tests/component/deb/__init__.py | 4 +-- tests/component/deb/test_clone.py | 2 +- tests/component/deb/test_import_dsc.py | 1 - tests/component/rpm/__init__.py | 6 ++-- tests/test_Config.py | 10 +++++-- tests/test_GitRepository.py | 33 ++++++++++++++++++++++ tests/test_GitVfs.py | 3 +- tests/testutils/__init__.py | 11 +++++--- tests/testutils/debiangittestrepo.py | 3 +- tests/testutils/gbplogtester.py | 1 + 54 files changed, 263 insertions(+), 202 deletions(-) diff --git a/examples/wrap_cl.py b/examples/wrap_cl.py index 5f1c0c85..c4c6f8ba 100644 --- a/examples/wrap_cl.py +++ b/examples/wrap_cl.py @@ -8,6 +8,7 @@ import textwrap import gbp.dch + def format_changelog_entry(commit_info, options, last_commit=False): entry = gbp.dch.format_changelog_entry(commit_info, options, last_commit) if entry: diff --git a/examples/zeitgeist-git.py b/examples/zeitgeist-git.py index dae1dbc5..8e04a18f 100755 --- a/examples/zeitgeist-git.py +++ b/examples/zeitgeist-git.py @@ -48,14 +48,14 @@ else: try: CLIENT = ZeitgeistClient() except RuntimeError as e: - print("Unable to connect to Zeitgeist, won't send events. Reason: '%s'" %e) + print("Unable to connect to Zeitgeist, won't send events. Reason: '%s'" % e) def get_repo(): """Get uri of remote repository and its name""" repo = None uri = subprocess.Popen(['git', 'config', '--get', 'remote.origin.url'], - stdout=subprocess.PIPE).communicate()[0] + stdout=subprocess.PIPE).communicate()[0] if uri: uri = uri.strip().decode(sys.getfilesystemencoding()) @@ -65,7 +65,7 @@ def get_repo(): sep = ':' try: repo = unicode(uri.rsplit(sep, 1)[1]) - except IndexError: # no known separator + except IndexError: # no known separator repo = uri repo = repo.rsplit(u'.git', 1)[0] return repo, uri @@ -86,19 +86,18 @@ def main(argv): origin = uri subject = Subject.new_for_values( - uri = uri, - interpretation = Interpretation.DOCUMENT.TEXT_DOCUMENT.PLAIN_TEXT_DOCUMENT.SOURCE_CODE.uri, - manifestation = Manifestation.FILE_DATA_OBJECT.uri, - text = repo, - origin = origin) + uri=uri, + interpretation=Interpretation.DOCUMENT.TEXT_DOCUMENT.PLAIN_TEXT_DOCUMENT.SOURCE_CODE.uri, + manifestation=Manifestation.FILE_DATA_OBJECT.uri, + text=repo, + origin=origin) event = Event.new_for_values( - timestamp = int(time.time() * 1000), - interpretation = interpretation, - manifestation = Manifestation.USER_ACTIVITY.uri, - actor = "application://gitg.desktop", - subjects = [subject]) + timestamp=int(time.time() * 1000), + interpretation=interpretation, + manifestation=Manifestation.USER_ACTIVITY.uri, + actor="application://gitg.desktop", + subjects=[subject]) CLIENT.insert_event(event) if __name__ == '__main__': main(sys.argv) - diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py index c33b4d97..fb630892 100644 --- a/gbp/command_wrappers.py +++ b/gbp/command_wrappers.py @@ -21,7 +21,6 @@ git-buildpackage and friends import subprocess import os -import os.path import signal import gbp.log as log diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py index b3b82254..6a240ec1 100644 --- a/gbp/deb/__init__.py +++ b/gbp/deb/__init__.py @@ -27,6 +27,7 @@ from gbp.git import GitRepositoryError from gbp.deb.changelog import ChangeLog, NoChangeLogError from gbp.deb.policy import DebianPkgPolicy + class DpkgCompareVersions(gbpc.Command): dpkg = '/usr/bin/dpkg' @@ -43,16 +44,16 @@ class DpkgCompareVersions(gbpc.Command): @raises CommandExecFailed: if the version comparison fails """ self.run_error = "Couldn't compare %s with %s" % (version1, version2) - res = self.call([ version1, 'lt', version2 ]) - if res not in [ 0, 1 ]: + res = self.call([version1, 'lt', version2]) + if res not in [0, 1]: if self.stderr: self.run_error += ' (%s)' % self.stderr raise gbpc.CommandExecFailed("%s: bad return code %d" % (self.run_error, res)) if res == 0: return -1 elif res == 1: - res = self.call([ version1, 'gt', version2 ]) - if res not in [ 0, 1 ]: + res = self.call([version1, 'gt', version2]) + if res not in [0, 1]: if self.stderr: self.run_error += ' (%s)' % self.stderr raise gbpc.CommandExecFailed("%s: bad return code %d" % (self.run_error, res)) diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py index fa4ba10e..06daebe2 100644 --- a/gbp/deb/changelog.py +++ b/gbp/deb/changelog.py @@ -23,10 +23,12 @@ import os import subprocess from gbp.command_wrappers import Command + class NoChangeLogError(Exception): """No changelog found""" pass + class ParseChangeLogError(Exception): """Problem parsing changelog""" pass @@ -92,9 +94,9 @@ class ChangeLog(object): def _parse(self): """Parse a changelog based on the already read contents.""" cmd = subprocess.Popen(['dpkg-parsechangelog', '-l-'], - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) (output, errors) = cmd.communicate(self._contents) if cmd.returncode: raise ParseChangeLogError("Failed to parse changelog. " @@ -138,8 +140,8 @@ class ChangeLog(object): @property def version(self): - """The full version string""" - return self._cp['Version'] + """The full version string""" + return self._cp['Version'] @property def upstream_version(self): @@ -198,7 +200,7 @@ class ChangeLog(object): """ section = '' for line in self._contents.split('\n'): - if line and line[0] not in [ ' ', '\t' ]: + if line and line[0] not in [' ', '\t']: section += line else: if section: diff --git a/gbp/deb/control.py b/gbp/deb/control.py index 603b3de7..efa92cac 100644 --- a/gbp/deb/control.py +++ b/gbp/deb/control.py @@ -19,14 +19,17 @@ import email import os + class NoControlError(Exception): """No control found""" pass + class ParseControlError(Exception): """Problem parsing control""" pass + class Control(object): """A Debian control""" diff --git a/gbp/deb/dscfile.py b/gbp/deb/dscfile.py index e64cf565..e81e0bbd 100644 --- a/gbp/deb/dscfile.py +++ b/gbp/deb/dscfile.py @@ -29,16 +29,16 @@ class DscFile(object): compressions = r"(%s)" % '|'.join(DebianUpstreamSource.known_compressions()) pkg_re = re.compile(r'Source:\s+(?P.+)\s*') version_re = re.compile(r'Version:\s((?P\d+)\:)?' - '(?P[%s]+)\s*$' + '(?P[%s]+)\s*$' % DebianPkgPolicy.debianversion_chars) tar_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' - '(\.orig)?\.tar\.%s)' % compressions) + '(\.orig)?\.tar\.%s)' % compressions) add_tar_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' '\.orig-(?P[a-z0-9-]+)\.tar\.%s)' % compressions) diff_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' - '\.diff.(gz|bz2))') + '\.diff.(gz|bz2))') deb_tgz_re = re.compile(r'^\s\w+\s\d+\s+(?P[^_]+_[^_]+' - '\.debian.tar.%s)' % compressions) + '\.debian.tar.%s)' % compressions) format_re = re.compile(r'Format:\s+(?P[0-9.]+)\s*') def __init__(self, dscfile): @@ -63,7 +63,7 @@ class DscFile(object): self.upstream_version = "-".join(m.group('version').split("-")[0:-1]) self.native = False else: - self.native = True # Debian native package + self.native = True # Debian native package self.upstream_version = m.group('version') if m.group('epoch'): self.epoch = m.group('epoch') @@ -113,7 +113,7 @@ class DscFile(object): self.additional_tarballs = dict(add_tars) def _get_version(self): - version = [ "", self.epoch + ":" ][len(self.epoch) > 0] + version = ["", self.epoch + ":"][len(self.epoch) > 0] if self.native: version += self.upstream_version else: diff --git a/gbp/deb/format.py b/gbp/deb/format.py index b9c4eb0f..f3d444a7 100644 --- a/gbp/deb/format.py +++ b/gbp/deb/format.py @@ -16,9 +16,11 @@ # """Parse debian/source/format""" + class DebianSourceFormatError(Exception): pass + class DebianSourceFormat(object): """ Contents of debian/source/format @@ -47,8 +49,7 @@ class DebianSourceFormat(object): self._version = parts[0] if len(parts) == 2: - if (parts[1][0] == '(' and - parts[1][-1] == ')'): + if (parts[1][0] == '(' and parts[1][-1] == ')'): self._type = parts[1][1:-1] else: raise DebianSourceFormatError("Cannot get source format from " diff --git a/gbp/deb/pristinetar.py b/gbp/deb/pristinetar.py index ab7fbd65..a80fd4b3 100644 --- a/gbp/deb/pristinetar.py +++ b/gbp/deb/pristinetar.py @@ -20,6 +20,7 @@ from gbp.pkg import compressor_opts from gbp.pkg.pristinetar import PristineTar from gbp.deb import DebianPkgPolicy + class DebianPristineTar(PristineTar): """The pristine-tar branch in a Debian git repository""" def has_commit(self, package, version, comp_type=None): @@ -63,4 +64,3 @@ class DebianPristineTar(PristineTar): output_dir, component=component) super(DebianPristineTar, self).checkout(name) - diff --git a/gbp/deb/source.py b/gbp/deb/source.py index 2466ab90..7b8ef98e 100644 --- a/gbp/deb/source.py +++ b/gbp/deb/source.py @@ -22,6 +22,7 @@ from gbp.deb.changelog import ChangeLog import six + class FileVfs(object): def __init__(self, dir): """ @@ -36,9 +37,11 @@ class FileVfs(object): flags = flags or 'r' return open(os.path.join(self._dir, path), flags) + class DebianSourceError(Exception): pass + class DebianSource(object): """ A debianized source tree @@ -68,10 +71,10 @@ class DebianSource(object): if f.type: return f.type == 'native' except IOError as e: - pass # Fall back to changelog parsing + pass # Fall back to changelog parsing try: - return not '-' in self.changelog.version + return '-' not in self.changelog.version except IOError as e: raise DebianSourceError("Failed to determine source format: %s" % e) diff --git a/gbp/deb/uscan.py b/gbp/deb/uscan.py index d81492a5..4613b960 100644 --- a/gbp/deb/uscan.py +++ b/gbp/deb/uscan.py @@ -16,11 +16,15 @@ # """Interface to uscan""" -import os, re, subprocess +import os +import re +import subprocess + class UscanError(Exception): pass + class Uscan(object): cmd = '/usr/bin/uscan' @@ -84,7 +88,7 @@ class Uscan(object): for n in ('package', 'upstream-version', 'upstream-url'): - m = re.match("<%s>(.*)" % (n,n), row) + m = re.match("<%s>(.*)" % (n, n), row) if m: d[n] = m.group(1) d["ext"] = os.path.splitext(d['upstream-url'])[1] @@ -94,10 +98,10 @@ class Uscan(object): # Fall back to the upstream source name otherwise if not os.path.exists(source): - source = "../%s" % d['upstream-url'].rsplit('/',1)[1] + source = "../%s" % d['upstream-url'].rsplit('/', 1)[1] if not os.path.exists(source): raise UscanError("Couldn't find tarball at '%s'" % - source) + source) except KeyError as e: raise UscanError("Couldn't find '%s' in uscan output" % e.args[0]) @@ -157,7 +161,7 @@ class Uscan(object): msg = None for n in ('errors', 'warnings'): - m = re.search("<%s>(.*)" % (n,n), out, re.DOTALL) + m = re.search("<%s>(.*)" % (n, n), out, re.DOTALL) if m: msg = "Uscan failed: %s" % m.group(1) break @@ -166,7 +170,6 @@ class Uscan(object): msg = "Uscan failed - debug by running 'uscan --verbose'" raise UscanError(msg) - def scan(self, destdir='..'): """Invoke uscan to fetch a new upstream version""" p = subprocess.Popen(['uscan', '--symlink', '--destdir=%s' % destdir, diff --git a/gbp/git/__init__.py b/gbp/git/__init__.py index 81e1422d..5e5240df 100644 --- a/gbp/git/__init__.py +++ b/gbp/git/__init__.py @@ -19,13 +19,14 @@ import calendar import dateutil.parser -from gbp.git.modifier import GitModifier -from gbp.git.commit import GitCommit -from gbp.git.errors import GitError -from gbp.git.repository import GitRepository, GitRepositoryError -from gbp.git.fastimport import FastImport -from gbp.git.args import GitArgs -from gbp.git.vfs import GitVfs +from gbp.git.modifier import GitModifier # noqa: F401 +from gbp.git.commit import GitCommit # noqa: F401 +from gbp.git.errors import GitError # noqa: F401 +from gbp.git.repository import ( # noqa: F401 + GitRepository, GitRepositoryError) +from gbp.git.fastimport import FastImport # noqa: F401 +from gbp.git.args import GitArgs # noqa: F401 +from gbp.git.vfs import GitVfs # noqa: F401 def rfc822_date_to_git(rfc822_date): diff --git a/gbp/git/args.py b/gbp/git/args.py index 197097f4..95e50116 100644 --- a/gbp/git/args.py +++ b/gbp/git/args.py @@ -21,6 +21,7 @@ Git command argument handling helpers import six import collections + class GitArgs(object): """ Handle arguments to git commands @@ -106,4 +107,3 @@ class GitArgs(object): else: self.add(noopt) return self - diff --git a/gbp/git/commit.py b/gbp/git/commit.py index cfc5d0c7..1a9912f8 100644 --- a/gbp/git/commit.py +++ b/gbp/git/commit.py @@ -18,7 +18,6 @@ import re -from gbp.git.errors import GitError class GitCommit(object): """A git commit""" @@ -44,5 +43,3 @@ class GitCommit(object): @rtype: C{bool} """ return True if GitCommit.sha1_re.match(value) else False - - diff --git a/gbp/git/errors.py b/gbp/git/errors.py index 47122b8e..377e468a 100644 --- a/gbp/git/errors.py +++ b/gbp/git/errors.py @@ -16,7 +16,7 @@ # """Git base error exception""" + class GitError(Exception): """Exception thrown by Git related classes""" pass - diff --git a/gbp/git/fastimport.py b/gbp/git/fastimport.py index 1195fee6..f5a6b678 100644 --- a/gbp/git/fastimport.py +++ b/gbp/git/fastimport.py @@ -21,12 +21,13 @@ import subprocess import time from gbp.errors import GbpError + class FastImport(object): """Add data to a git repository using I{git fast-import}""" _bufsize = 1024 m_regular = 644 - m_exec = 755 + m_exec = 755 m_symlink = 120000 def __init__(self, repo): @@ -36,7 +37,7 @@ class FastImport(object): """ self._repo = repo try: - self._fi = subprocess.Popen([ 'git', 'fast-import', '--quiet'], + self._fi = subprocess.Popen(['git', 'fast-import', '--quiet'], stdin=subprocess.PIPE, cwd=repo.path) self._out = self._fi.stdin except OSError as err: diff --git a/gbp/git/modifier.py b/gbp/git/modifier.py index 847c4e6d..cb8bec19 100644 --- a/gbp/git/modifier.py +++ b/gbp/git/modifier.py @@ -21,14 +21,17 @@ like committing changes or authoring a patch """ import six -import calendar, datetime +import calendar +import datetime from gbp.git.errors import GitError + class GitModifierError(GitError): """Exception thrown by L{GitModifier}""" pass + class GitTz(datetime.tzinfo): """Simple class to store the utc offset only""" def __init__(self, offset_sec=0, *args, **kwargs): @@ -41,6 +44,7 @@ class GitTz(datetime.tzinfo): def dst(self, dt): return datetime.timedelta(0) + class GitModifier(object): """Stores authorship/committer information""" def __init__(self, name=None, email=None, date=None): @@ -64,16 +68,16 @@ class GitModifier(object): timestamp, offset = date.split() offset_h = int(offset[:-2]) offset_m = int(offset[-2:]) - tz = GitTz(offset_h*3600 + offset_m*60) + tz = GitTz(offset_h * 3600 + offset_m * 60) self._date = datetime.datetime.fromtimestamp(int(timestamp), tz) - elif type(date) in [ type(0), type(0.0) ]: + elif type(date) in [type(0), type(0.0)]: self._date = datetime.datetime.fromtimestamp(date, tz) elif isinstance(date, datetime.datetime): if date.tzinfo: self._date = date else: self._date = date.replace(tzinfo=tz) - elif date != None: + elif date is not None: raise ValueError("Date '%s' not timestamp, " "datetime object or git raw date" % date) @@ -154,7 +158,7 @@ class GitModifier(object): @staticmethod def keys(): - return [ 'name', 'email', 'date' ] + return ['name', 'email', 'date'] def items(self): items = [] diff --git a/gbp/git/vfs.py b/gbp/git/vfs.py index b34e5736..191cf621 100644 --- a/gbp/git/vfs.py +++ b/gbp/git/vfs.py @@ -17,7 +17,8 @@ """Make blobs in a git repository accessible as file like objects""" from six import StringIO -from gbp.git.repository import GitRepositoryError +from gbp.git.repository import GitRepositoryError + class GitVfs(object): diff --git a/gbp/log.py b/gbp/log.py index 9248ec94..ae4821d6 100644 --- a/gbp/log.py +++ b/gbp/log.py @@ -124,24 +124,30 @@ def err(msg): """Logs a message with level ERROR on the GBP logger""" LOGGER.error(msg) + def error(msg): err(msg) + def warn(msg): """Logs a message with level WARNING on the GBP logger""" LOGGER.warning(msg) + def warning(msg): warn(msg) + def info(msg): """Logs a message with level INFO on the GBP logger""" LOGGER.info(msg) + def debug(msg): """Logs a message with level DEBUG on the GBP logger""" LOGGER.debug(msg) + def _parse_color_scheme(color_scheme=""): """Set logging colors""" scheme = {} @@ -159,9 +165,11 @@ def _parse_color_scheme(color_scheme=""): except ValueError: try: scheme[level] = COLORS[color.lower()] - except KeyError: pass + except KeyError: + pass return scheme + def setup(color, verbose, color_scheme=""): """Basic logger setup""" LOGGER.set_color(color) @@ -176,4 +184,3 @@ def setup(color, verbose, color_scheme=""): logging.setLoggerClass(GbpLogger) LOGGER = getLogger("gbp") - diff --git a/gbp/pkg/pristinetar.py b/gbp/pkg/pristinetar.py index 91977897..ac24998f 100644 --- a/gbp/pkg/pristinetar.py +++ b/gbp/pkg/pristinetar.py @@ -20,9 +20,10 @@ import os import gbp.log from gbp.command_wrappers import Command + class PristineTar(Command): """The pristine-tar branch in a git repository""" - cmd='/usr/bin/pristine-tar' + cmd = '/usr/bin/pristine-tar' branch = 'pristine-tar' def __init__(self, repo): @@ -79,4 +80,3 @@ class PristineTar(Command): self.run_error = ("Couldn't commit to '%s' with upstream '%s': {stderr}" % (self.branch, upstream)) self.__call__(['commit', archive, upstream]) - diff --git a/gbp/rpm/git.py b/gbp/rpm/git.py index 77cb3116..5f11a082 100644 --- a/gbp/rpm/git.py +++ b/gbp/rpm/git.py @@ -15,7 +15,6 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, please see # -import re from gbp.format import format_str from gbp.errors import GbpError diff --git a/gbp/rpm/lib_rpm.py b/gbp/rpm/lib_rpm.py index 4abc6665..5fc0354e 100644 --- a/gbp/rpm/lib_rpm.py +++ b/gbp/rpm/lib_rpm.py @@ -26,8 +26,8 @@ try: librpm = __import__(RpmPkgPolicy.python_rpmlib_module_name) except ImportError: gbp.log.warn("Failed to import '%s' as rpm python module, using host's " - "default rpm library instead" % - RpmPkgPolicy.python_rpmlib_module_name) + "default rpm library instead" % + RpmPkgPolicy.python_rpmlib_module_name) import rpm as librpm # Module initialization @@ -44,4 +44,3 @@ def get_librpm_log(truncate=True): if truncate: _rpmlogfd.truncate(0) return log - diff --git a/gbp/scripts/common/buildpackage.py b/gbp/scripts/common/buildpackage.py index 676ee742..5944abf5 100644 --- a/gbp/scripts/common/buildpackage.py +++ b/gbp/scripts/common/buildpackage.py @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : # -# (C) 2006-2011 Guido Guenther +# (C) 2006-2011, 2016 Guido Guenther # (C) 2012 Intel Corporation # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -18,7 +18,8 @@ # """Common functionality for Debian and RPM buildpackage scripts""" -import os, os.path +import os +import os.path import pipes import tempfile import shutil @@ -112,7 +113,7 @@ def git_archive_single(treeish, output, prefix, comp_type, comp_level, comp_opts raise GbpError("Error creating %s: %d" % (output, ret)) -#{ Functions to handle export-dir +# Functions to handle export-dir def dump_tree(repo, export_dir, treeish, with_submodules, recursive=True): "dump a tree to output_dir" output_dir = os.path.dirname(export_dir) @@ -147,7 +148,7 @@ def dump_tree(repo, export_dir, treeish, with_submodules, recursive=True): ret = pipe.copy('', '') os.chdir(top) if ret: - raise GbpError("Error in dump_tree archive pipe in submodule %s" % subdir) + raise GbpError("Error in dump_tree archive pipe in submodule %s" % subdir) except OSError as err: gbp.log.err("Error dumping tree to %s: %s" % (output_dir, err[0])) return False diff --git a/gbp/scripts/common/import_orig.py b/gbp/scripts/common/import_orig.py index 24a56f10..069a36da 100644 --- a/gbp/scripts/common/import_orig.py +++ b/gbp/scripts/common/import_orig.py @@ -35,6 +35,7 @@ try: except ImportError: pass + def orig_needs_repack(upstream_source, options): """ Determine if the upstream sources needs to be repacked diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py index e0abc196..fca4ec31 100644 --- a/gbp/scripts/common/pq.py +++ b/gbp/scripts/common/pq.py @@ -176,6 +176,7 @@ def write_patch_file(filename, commit_info, diff): DEFAULT_PATCH_NUM_PREFIX_FORMAT = "%04d-" + def format_patch(outdir, repo, commit_info, series, numbered=True, path_exclude_regex=None, topic='', name=None, renumber=False, patch_num_prefix_format=DEFAULT_PATCH_NUM_PREFIX_FORMAT): @@ -188,10 +189,10 @@ def format_patch(outdir, repo, commit_info, series, numbered=True, try: num_prefix = str(patch_num_prefix_format) % (len(series) + 1) \ - if numbered else '' + if numbered else '' except Exception: - gbp.log.warn("Bad format format string '%s', " \ - "falling back to default '%s'" % \ + gbp.log.warn("Bad format format string '%s', " + "falling back to default '%s'" % (str(patch_num_prefix_format), DEFAULT_PATCH_NUM_PREFIX_FORMAT)) num_prefix = DEFAULT_PATCH_NUM_PREFIX_FORMAT % (len(series) + 1) @@ -200,7 +201,7 @@ def format_patch(outdir, repo, commit_info, series, numbered=True, if renumber: # Remove any existing numeric prefix if the patch # should be renumbered - name = re.sub('^\d+[-_]*', '', name) + name = re.sub('^\d+[-_]*', '', name) else: # Otherwise, clear proposed prefix num_prefix = '' @@ -214,9 +215,8 @@ def format_patch(outdir, repo, commit_info, series, numbered=True, filepath = os.path.join(outdir, filename) # Make sure that we don't overwrite existing patches in the series if filepath in series: - presuffix = '-%d' % \ - len([p for p in series \ - if p.startswith(os.path.splitext(filepath)[0])]) + presuffix = '-%d' % len([p for p in series + if p.startswith(os.path.splitext(filepath)[0])]) filename = num_prefix + base + presuffix + suffix filepath = os.path.join(outdir, filename) diff --git a/gbp/scripts/config.py b/gbp/scripts/config.py index 72bcc886..9872d7fc 100755 --- a/gbp/scripts/config.py +++ b/gbp/scripts/config.py @@ -18,7 +18,7 @@ """Query and display config file values""" import sys -import os, os.path +import os from gbp.config import GbpOptionParser from gbp.errors import GbpError from gbp.scripts.supercommand import import_command diff --git a/gbp/scripts/create_remote_repo.py b/gbp/scripts/create_remote_repo.py index ffc32eaa..85a49b54 100644 --- a/gbp/scripts/create_remote_repo.py +++ b/gbp/scripts/create_remote_repo.py @@ -70,6 +70,7 @@ def print_config(remote, branches): remote = %s merge = refs/heads/%s""" % (branch, remote['name'], branch)) + def sort_dict(d): """Return a sorted list of (key, value) tuples""" s = [] @@ -77,6 +78,7 @@ def sort_dict(d): s.append((key, d[key])) return s + def parse_url(remote_url, name, pkg, template_dir=None): """ Sanity check our remote URL @@ -116,7 +118,7 @@ def parse_url(remote_url, name, pkg, template_dir=None): else: raise GbpError("URL must use ssh protocol.") - if not '%(pkg)s' in remote_url and not remote_url.endswith(".git"): + if '%(pkg)s' not in remote_url and not remote_url.endswith(".git"): raise GbpError("URL needs to contain either a repository name or '%(pkg)s'") if ":" in frags.netloc: @@ -162,7 +164,7 @@ def build_remote_script(remote, branch): args['git-init-args'] = '--bare --shared' if args['template-dir']: args['git-init-args'] += (' --template=%s' - % args['template-dir']) + % args['template-dir']) remote_script_pattern = ['', 'set -e', 'umask 002', @@ -214,7 +216,7 @@ def read_yn(): if old_settings: termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) - if ch in ( 'y', 'Y' ): + if ch in ('y', 'Y'): return True else: return False @@ -293,7 +295,7 @@ def parse_args(argv, sections=[]): # section to parse, this makes e.g. --help work as expected: for arg in argv: if arg.startswith('--remote-config='): - sections = ['remote-config %s' % arg.split('=',1)[1]] + sections = ['remote-config %s' % arg.split('=', 1)[1]] break else: sections = [] @@ -325,12 +327,12 @@ def main(argv): try: branches = [] - for branch in [ options.debian_branch, options.upstream_branch ]: + for branch in [options.debian_branch, options.upstream_branch]: if repo.has_branch(branch): - branches += [ branch ] + branches += [branch] if repo.has_pristine_tar_branch() and options.pristine_tar: - branches += [ repo.pristine_tar_branch ] + branches += [repo.pristine_tar_branch] try: cp = ChangeLog(filename=changelog) diff --git a/gbp/scripts/import_dscs.py b/gbp/scripts/import_dscs.py index 7e049a9e..b592d81d 100644 --- a/gbp/scripts/import_dscs.py +++ b/gbp/scripts/import_dscs.py @@ -29,6 +29,7 @@ from gbp.scripts import import_dsc from gbp.config import GbpOptionParser import gbp.log + class DscCompareVersions(DpkgCompareVersions): def __init__(self): DpkgCompareVersions.__init__(self) @@ -51,8 +52,8 @@ def fetch_snapshots(pkg, downloaddir): gbp.log.info("Downloading snapshots of '%s' to '%s'..." % (pkg, downloaddir)) - debsnap = gbpc.Command("debsnap", [ '--force', '--destdir=%s' % - (downloaddir), pkg]) + debsnap = gbpc.Command("debsnap", ['--force', '--destdir=%s' % + (downloaddir), pkg]) try: debsnap() except gbpc.CommandExecFailed: @@ -68,6 +69,7 @@ def fetch_snapshots(pkg, downloaddir): return [os.path.join(downloaddir, dsc) for dsc in dscs] + def set_gbp_conf_files(): """ Filter out all gbp.conf files that are local to the git repository and set @@ -78,13 +80,14 @@ def set_gbp_conf_files(): os.environ['GBP_CONF_FILES'] = gbp_conf_files gbp.log.debug("Setting GBP_CONF_FILES to '%s'" % gbp_conf_files) + def print_help(): print("""Usage: gbp import-dscs [options] [gbp-import-dsc options] /path/to/dsc1 [/path/to/dsc2] ... gbp import-dscs --debsnap [options] [gbp-import-dsc options] package Options: - --debsnap: use debsnap command to download packages + --debsnap: use debsnap command to download packages --ignore-repo-config ignore gbp.conf in git repo """) @@ -129,7 +132,7 @@ def main(argv): if use_debsnap: dirs['tmp'] = os.path.abspath(tempfile.mkdtemp()) - dscs = [ DscFile.parse(f) for f in fetch_snapshots(pkg, dirs['tmp']) ] + dscs = [DscFile.parse(f) for f in fetch_snapshots(pkg, dirs['tmp'])] dscs.sort(cmp=dsc_cmp) importer = GitImportDsc(import_args) diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index 8c51a5f8..67ad842d 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -49,6 +49,7 @@ class RollbackError(GitRepositoryError): def __str__(self): return "%s %s" % (self.msg, self.errors) + class ImportOrigDebianGitRepository(DebianGitRepository): """ Like a DebianGitRepository but can also perform rollbacks and knows @@ -441,7 +442,6 @@ def build_parser(name): dest="components") cmd_group.add_config_file_option(option_name="postimport", dest="postimport") - parser.add_boolean_config_file_option(option_name="interactive", dest='interactive') parser.add_boolean_config_file_option(option_name="rollback", diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 3cdec8a0..51539dc1 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -32,15 +32,15 @@ from gbp.errors import GbpError import gbp.log from gbp.patch_series import (PatchSeries, Patch) from gbp.scripts.common.pq import (is_pq_branch, pq_branch_name, pq_branch_base, - parse_gbp_commands, format_patch, - switch_to_pq_branch, apply_single_patch, - apply_and_commit_patch, switch_pq, - drop_pq, get_maintainer_from_control) + parse_gbp_commands, format_patch, + switch_to_pq_branch, apply_single_patch, + apply_and_commit_patch, switch_pq, + drop_pq, get_maintainer_from_control) from gbp.scripts.common import ExitCodes from gbp.dch import extract_bts_cmds PATCH_DIR = "debian/patches/" -SERIES_FILE = os.path.join(PATCH_DIR,"series") +SERIES_FILE = os.path.join(PATCH_DIR, "series") def parse_old_style_topic(commit_info): @@ -158,12 +158,12 @@ def commit_patches(repo, branch, patches, options): vfs = gbp.git.vfs.GitVfs(repo, branch) try: oldseries = vfs.open('debian/patches/series') - oldpatches = [ p.strip() for p in oldseries.readlines() ] + oldpatches = [p.strip() for p in oldseries.readlines()] oldseries.close() except IOError: # No series file yet oldpatches = [] - newpatches = [ p[len(PATCH_DIR):] for p in patches ] + newpatches = [p[len(PATCH_DIR):] for p in patches] # FIXME: handle case were only the contents of the patches changed added, removed = compare_series(oldpatches, newpatches) @@ -338,7 +338,7 @@ def import_quilt_patches(repo, branch, series, tries, force, pq_from, else: # All patches applied successfully break - i-=1 + i -= 1 else: raise GbpError("Couldn't apply patches") @@ -368,20 +368,24 @@ def rebase_pq(repo, branch, pq_from, upstream_tag): GitCommand("rebase", cwd=repo.path)([_from]) +def usage_msg(): + return """%prog [options] action - maintain patches on a patch queue branch +Actions: + export export the patch queue associated to the current branch + into a quilt patch series in debian/patches/ and update the + series file. + import create a patch queue branch from quilt patches in debian/patches. + rebase switch to patch queue branch associated to the current + branch and rebase against current branch. + drop drop (delete) the patch queue associated to the current branch. + apply apply a patch + switch switch to patch-queue branch and vice versa""" + + def build_parser(name): try: parser = GbpOptionParserDebian(command=os.path.basename(name), - usage="%prog [options] action - maintain patches on a patch queue branch\n" - "Actions:\n" - " export export the patch queue associated to the current branch\n" - " into a quilt patch series in debian/patches/ and update the\n" - " series file.\n" - " import create a patch queue branch from quilt patches in debian/patches.\n" - " rebase switch to patch queue branch associated to the current\n" - " branch and rebase against current branch.\n" - " drop drop (delete) the patch queue associated to the current branch.\n" - " apply apply a patch\n" - " switch switch to patch-queue branch and vice versa") + usage=usage_msg()) except GbpError as err: gbp.log.err(err) return None @@ -459,7 +463,7 @@ def main(argv): options.upstream_tag) current = repo.get_branch() gbp.log.info("%d patches listed in '%s' imported on '%s'" % - (num, series, current)) + (num, series, current)) elif action == "drop": drop_pq(repo, current) elif action == "rebase": diff --git a/gbp/scripts/pq_rpm.py b/gbp/scripts/pq_rpm.py index 6e7b4ef4..d2f204d9 100755 --- a/gbp/scripts/pq_rpm.py +++ b/gbp/scripts/pq_rpm.py @@ -55,6 +55,7 @@ def is_ancestor(repo, parent, child): merge_base = None return merge_base == parent_sha1 + def generate_patches(repo, start, end, outdir, options): """ Generate patch files from git @@ -100,7 +101,7 @@ def generate_patches(repo, start, end, outdir, options): 'gbp-rpm', ('ignore'), ('if', 'ifarch')) - if not 'ignore' in cmds: + if 'ignore' not in cmds: patch_fn = format_patch(outdir, repo, info, patches, options.patch_numbers) if patch_fn: @@ -223,7 +224,7 @@ def safe_patches(queue): if len(queue) > 0: gbp.log.debug("Safeing patches '%s' in '%s'" % - (os.path.dirname(queue[0].path), tmpdir)) + (os.path.dirname(queue[0].path), tmpdir)) for patch in queue: base, _archive_fmt, comp = parse_archive_filename(patch.path) uncompressors = {'gzip': gzip.open, 'bzip2': bz2.BZ2File} @@ -315,7 +316,7 @@ def import_spec_patches(repo, options): if not queue: return gbp.log.info("Trying to apply patches from branch '%s' onto '%s'" % - (base, upstream_commit)) + (base, upstream_commit)) for patch in queue: gbp.log.debug("Applying %s" % patch.path) apply_and_commit_patch(repo, patch, packager) @@ -463,4 +464,3 @@ def main(argv): if __name__ == '__main__': sys.exit(main(sys.argv)) - diff --git a/gbp/scripts/supercommand.py b/gbp/scripts/supercommand.py index 2d0a9f47..e9e03ab2 100644 --- a/gbp/scripts/supercommand.py +++ b/gbp/scripts/supercommand.py @@ -26,7 +26,8 @@ import sys # Command is this module and common/ is shared code # so we don't allow these to be imported: -invalid_modules = [ 'common', 'supercommand' ] +invalid_modules = ['common', 'supercommand'] + def sanitize(cmd): """ @@ -35,6 +36,7 @@ def sanitize(cmd): """ return cmd.replace('-', '_') + def usage(): print(""" Usage: @@ -50,6 +52,7 @@ The most commonly used commands are: Use '--list-cmds' to list all available commands. """) + def version(prog): try: from gbp.version import gbp_version @@ -64,7 +67,7 @@ def import_command(cmd): """ modulename = sanitize(cmd) if (not re.match(r'[a-z][a-z0-9_]', modulename) or - modulename in invalid_modules): + modulename in invalid_modules): raise ImportError('Illegal module name %s' % modulename) return __import__('gbp.scripts.%s' % modulename, fromlist='main', level=0) @@ -75,7 +78,7 @@ def pymod_to_cmd(mod): >>> pymod_to_cmd('/x/y/z/a_cmd.py') 'a-cmd' """ - return os.path.basename(mod.rsplit('.', 1)[0]).replace('_','-') + return os.path.basename(mod.rsplit('.', 1)[0]).replace('_', '-') def get_available_commands(path): @@ -125,10 +128,10 @@ def supercommand(argv=None): elif cmd == 'help': usage() return 0 - elif cmd in [ '--version', 'version' ]: + elif cmd in ['--version', 'version']: version(argv[0]) return 0 - elif cmd in [ '--list-cmds', 'list-cmds' ]: + elif cmd in ['--list-cmds', 'list-cmds']: list_available_commands() return 0 diff --git a/gbp/tristate.py b/gbp/tristate.py index 46300298..d6ff8109 100644 --- a/gbp/tristate.py +++ b/gbp/tristate.py @@ -19,27 +19,28 @@ A switch with three states: on|off|auto """ + class Tristate(object): """Tri-state value: on, off or auto """ - ON = True # state is on == do it + ON = True # state is on == do it OFF = False # state is off == don't do it AUTO = -1 # autodetect == do if possible # We accept true as alias for on and false as alias for off - _VALID_NAMES = [ 'on', 'off', 'true', 'false', 'auto' ] + _VALID_NAMES = ['on', 'off', 'true', 'false', 'auto'] def __init__(self, val): - if type(val) in [ type(t) for t in (True, 1) ]: + if type(val) in [type(t) for t in (True, 1)]: if val > 0: self._state = self.ON elif val < 0: self._state = self.AUTO else: self._state = self.OFF - elif type(val) in [ type(t) for t in ("", u"") ]: - if val.lower() in [ 'on', 'true' ]: + elif type(val) in [type(t) for t in ("", u"")]: + if val.lower() in ['on', 'true']: self._state = self.ON - elif val.lower() in [ 'auto' ]: + elif val.lower() in ['auto']: self._state = self.AUTO else: self._state = self.OFF diff --git a/requirements.txt b/requirements.txt index f2669bbb..bd47cdaf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ coverage>=2.85 +flake8>=3 mock nose>=0.11.1 nosexcover>=1.0.7 diff --git a/setup.cfg b/setup.cfg index d443f2a7..5271e1a6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,6 +13,8 @@ target = build/apidocs/ fail-on = docstring_warning modules = gbp, tests/test_*.py -[pep8] +[flake8] # E501: ignore line length ignore=E501 +builtins=unicode,execfile,raw_input + diff --git a/setup.py b/setup.py index bbc0ba8a..766f1cf3 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ def fetch_version(): version = line.split(' ')[1].strip() break except OSError: - pass # Failing is fine, we just can't print the version then + pass # Failing is fine, we just can't print the version then with open('gbp/version.py', 'w') as f: f.write('"The current gbp version number"\n') diff --git a/tests/01_test_help.py b/tests/01_test_help.py index 8e0b10c0..8cfa3d24 100644 --- a/tests/01_test_help.py +++ b/tests/01_test_help.py @@ -2,7 +2,7 @@ """Check if --help works""" -from . import context +from . import context # noqa: F401 from .testutils.data import TestCaseWithData diff --git a/tests/02_test_upstream_source_tar_unpack.py b/tests/02_test_upstream_source_tar_unpack.py index 02b50439..e6440903 100644 --- a/tests/02_test_upstream_source_tar_unpack.py +++ b/tests/02_test_upstream_source_tar_unpack.py @@ -12,6 +12,7 @@ import six import gbp.pkg + class TestUnpack(unittest.TestCase): """Make sure we unpack gzip and bzip2 archives correctly""" archive_prefix = "archive" @@ -26,10 +27,10 @@ class TestUnpack(unittest.TestCase): assert os.path.exists(target), "%s does not exist" % target def _create_archive(self, comp): - filelist = [ 'README', 'setup.py' ] + filelist = ['README', 'setup.py'] name = "%s_0.1.tar.%s" % (self.archive_prefix, comp) - t = tarfile.open(name= name, mode='w:%s' % comp) + t = tarfile.open(name=name, mode='w:%s' % comp) for f in filelist: t.add(os.path.join(self.top, f), os.path.join(self._unpack_dir(comp), f)) @@ -41,7 +42,7 @@ class TestUnpack(unittest.TestCase): self.top = context.projectdir context.chdir(self.dir) self.archives = {} - for ext in [ "gz", "bz2" ]: + for ext in ["gz", "bz2"]: self.archives[ext] = self._create_archive(ext) def tearDown(self): @@ -50,12 +51,12 @@ class TestUnpack(unittest.TestCase): def test_upstream_source_type(self): for (comp, archive) in six.iteritems(self.archives): source = gbp.pkg.UpstreamSource(archive[0]) - assert source.is_orig() == True - assert source.is_dir() == False - assert source.unpacked == None + assert source.is_orig() is True + assert source.is_dir() is False + assert source.unpacked is None source.unpack(".") - assert source.is_orig() == True - assert source.is_dir() == False + assert source.is_orig() is True + assert source.is_dir() is False assert type(source.unpacked) == str def test_upstream_source_unpack(self): diff --git a/tests/03_test_dch_guess_version.py b/tests/03_test_dch_guess_version.py index 49b0e41a..bd4389f0 100644 --- a/tests/03_test_dch_guess_version.py +++ b/tests/03_test_dch_guess_version.py @@ -2,11 +2,12 @@ """Test L{Changelog}'s guess_version_from_upstream""" -from . import context +from . import context # noqa: F401 from . import testutils from gbp.scripts import dch + class TestGuessVersionFromUpstream(testutils.DebianGitTestRepo): """Test guess_version_from_upstream""" @@ -17,7 +18,6 @@ class TestGuessVersionFromUpstream(testutils.DebianGitTestRepo): uversion = '1.1' upstream_branch = 'upstream' - self.add_file('doesnot', 'matter') self.repo.create_branch('upstream') tag = self.repo.version_to_tag(tagformat, uversion) diff --git a/tests/04_test_submodules.py b/tests/04_test_submodules.py index 34dc9913..5cd86108 100644 --- a/tests/04_test_submodules.py +++ b/tests/04_test_submodules.py @@ -27,6 +27,7 @@ TMPDIR = None TESTFILE_NAME = "testfile" TESTDIR_NAME = "testdir" + class Submodule(object): """Class representing remote repo for Git submodule""" def __init__(self, name, tmpdir): @@ -53,6 +54,7 @@ def teardown(): """Test module teardown""" context.teardown() + def test_empty_has_submodules(): """Test empty repo for submodules""" ok_(not REPO.has_submodules()) @@ -87,6 +89,7 @@ def test_add_submodule(): REPO.add_submodule(SUBMODULES[0].dir) REPO.commit_all(msg='Added submodule %s' % SUBMODULES[0].dir) + def test_has_submodules(): """Check for submodules""" ok_(REPO.has_submodules()) @@ -97,8 +100,8 @@ def test_has_submodules(): def test_get_submodules(): """Check for submodules list of (name, hash)""" modules = REPO.get_submodules("master")[0] - eq_(modules[0] , 'test_submodule') - eq_(len(modules[1]) , 40) + eq_(modules[0], 'test_submodule') + eq_(len(modules[1]), 40) def test_dump_tree(): @@ -122,14 +125,15 @@ def test_dump_tree(): def test_create_tarballs(): """Create an upstream tarball""" # Tarball with submodules - changelog = { "Source": "test", "Upstream-Version": "0.1" } + changelog = {"Source": "test", "Upstream-Version": "0.1"} ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2", "9", True)) # Tarball without submodules - changelog = { "Source": "test", "Upstream-Version": "0.2" } + changelog = {"Source": "test", "Upstream-Version": "0.2"} ok_(buildpackage.git_archive(REPO, changelog, str(TMPDIR), "HEAD", "bzip2", "9", False)) + def test_create_zip_archives(): """Create an upstream zip archive""" git_archive_submodules(REPO, 'HEAD', 'with-submodules.zip', 'test', @@ -143,30 +147,33 @@ def test_create_zip_archives(): contents = ls_zip('without-submodules.zip') ok_('test/test_submodule/testfile' not in contents) + def test_check_tarfiles(): """Check the contents of the created tarfile""" # Check tarball with submodules tarobj = tarfile.open(TMPDIR.join("test_0.1.orig.tar.bz2"), 'r:*') files = tarobj.getmembers() - ok_("test-0.1/.gitmodules" in [ f.name for f in files ]) - eq_(len(files) , 10) + ok_("test-0.1/.gitmodules" in [f.name for f in files]) + eq_(len(files), 10) # Check tarball without submodules tarobj = tarfile.open(TMPDIR.join("test_0.2.orig.tar.bz2"), 'r:*') files = tarobj.getmembers() - ok_(("test-0.2/%s" % TESTFILE_NAME) in [ f.name for f in files ]) - eq_(len(files) , 6) + ok_(("test-0.2/%s" % TESTFILE_NAME) in [f.name for f in files]) + eq_(len(files), 6) + def test_add_whitespace_submodule(): """Add a second submodule with name containing whitespace""" REPO.add_submodule(SUBMODULES[1].dir) REPO.commit_all(msg='Added submodule %s' % SUBMODULES[0].dir) + def test_get_more_submodules(): """Check for submodules list of (name, hash)""" module = REPO.get_submodules("master") eq_(len(module), len(SUBMODULE_NAMES)) for module in REPO.get_submodules("master"): - eq_(len(module[1]) , 40) + eq_(len(module[1]), 40) ok_(os.path.basename(module[0]) in SUBMODULE_NAMES) diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py index 9b902e10..2355f1f9 100644 --- a/tests/05_test_detection.py +++ b/tests/05_test_detection.py @@ -10,6 +10,7 @@ from gbp.scripts import buildpackage from gbp.deb import (DebianPkgPolicy, orig_file) from gbp.errors import GbpError + class MockGitRepository: def __init__(self, with_branch=False, subject=None): self.with_branch = with_branch @@ -27,6 +28,7 @@ class MockGitRepository: def get_commit_info(self, commit): return {'subject': self.subject} + class TestDetection(unittest.TestCase): def setUp(self): self.tmpdir = context.new_tmpdir(__name__) diff --git a/tests/06_test_upstream_source.py b/tests/06_test_upstream_source.py index 3a6f92e8..18f6fbd4 100644 --- a/tests/06_test_upstream_source.py +++ b/tests/06_test_upstream_source.py @@ -12,6 +12,7 @@ import zipfile from gbp.pkg import UpstreamSource + class TestDir(unittest.TestCase): def setUp(self): self.tmpdir = context.new_tmpdir(__name__) @@ -29,6 +30,7 @@ class TestDir(unittest.TestCase): def tearDown(self): context.teardown() + class TestTar(unittest.TestCase): """Test if packing tar archives works""" def _check_tar(self, us, positive=[], negative=[]): @@ -92,4 +94,3 @@ class TestZip(unittest.TestCase): self.assertEqual(source.guess_version(), ('gbp', '0.1')) source.unpack(str(self.tmpdir)) self.assertNotEqual(source.unpacked, None) - diff --git a/tests/11_test_dch_main.py b/tests/11_test_dch_main.py index 5a537606..a6c7876d 100644 --- a/tests/11_test_dch_main.py +++ b/tests/11_test_dch_main.py @@ -50,7 +50,6 @@ cl_debian = """test-package (0.9-1) unstable; urgency=%s class TestScriptDch(DebianGitTestRepo): """Test git-dch""" - def setUp(self): DebianGitTestRepo.setUp(self) self.add_file("foo", "bar") @@ -70,11 +69,9 @@ class TestScriptDch(DebianGitTestRepo): "--upstream-branch=upstream", "--id-length=0", "--spawn-editor=/bin/true"] self.repo.create_tag(deb_tag, msg=deb_tag_msg, commit="HEAD~1") - def tearDown(self): DebianGitTestRepo.tearDown(self) - def run_dch(self, dch_options=None): # Take care to copy the list options = self.options[:] @@ -84,14 +81,12 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual(ret, 0) return open("debian/changelog").readlines() - def test_dch_main_new_upstream_version(self): """Test dch.py like gbp dch script does: new upstream version""" lines = self.run_dch() self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_release(self): """Test dch.py like gbp dch script does: new upstream version - release""" options = ["--release"] @@ -99,7 +94,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_auto(self): """Test dch.py like gbp dch script does: new upstream version - guess last commit""" options = ["--auto"] @@ -107,7 +101,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot(self): """Test dch.py like gbp dch script does: new upstream version - snapshot mode""" options = ["--snapshot"] @@ -118,7 +111,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_auto(self): """Test dch.py like gbp dch script does: new upstream version - two snapshots - auto""" options = ["--snapshot"] @@ -141,7 +133,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertIn(""" * added debian/control\n""", lines) self.assertIn(""" * added debian/compat\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_commit_auto(self): """Test dch.py like gbp dch script does: new upstream version - two committed snapshots - auto""" options = ["--commit"] @@ -168,7 +159,6 @@ class TestScriptDch(DebianGitTestRepo): # But its changelog must be included in the new one self.assertIn(""" * TEST-COMMITTED-SNAPSHOT\n""", lines) - def test_dch_main_new_upstream_version_with_auto_release(self): """Test dch.py like gbp dch script does: new upstream version - auto - release""" options = ["--auto", "--release"] @@ -176,10 +166,9 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (1.0-1) %s; urgency=%s\n" % (os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_auto_snapshot(self): """Test dch.py like gbp dch script does: new upstream version - auto - snapshot mode""" - options = [ "--auto", "--snapshot" ] + options = ["--auto", "--snapshot"] options.append("--snapshot") lines = self.run_dch(options) header = re.search(snap_header_1, lines[0]) @@ -188,7 +177,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot_release(self): """Test dch.py like gbp dch script does: new upstream version - snapshot - release""" options = ["--snapshot", "--release"] @@ -196,7 +184,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertRaises(SystemExit, self.run_dch, options) self.assertTrue("'--snapshot' and '--release' are incompatible options" in c.output()) - def test_dch_main_new_upstream_version_with_distribution(self): """Test dch.py like gbp dch script does: new upstream version - set distribution""" options = ["--distribution=testing", "--force-distribution"] @@ -204,7 +191,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_release_distribution(self): """Test dch.py like gbp dch script does: new upstream version - release - set distribution""" options = ["--release", "--distribution=testing", "--force-distribution"] @@ -212,7 +198,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (1.0-1) testing; urgency=%s\n" % default_urgency, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot_distribution(self): """Test dch.py like gbp dch script does: new upstream version - snapshot mode - do not set distribution""" options = ["--snapshot", "--distribution=testing"] @@ -223,7 +208,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_auto_distribution(self): """Test dch.py like gbp dch script does: new upstream version - two snapshots - do not set distribution""" options = ["--snapshot", "--distribution=testing"] @@ -249,7 +233,6 @@ class TestScriptDch(DebianGitTestRepo): # we do not commit self.assertNotIn(""" * TEST-COMMITTED-SNAPSHOT\n""", lines) - def test_dch_main_new_upstream_version_with_2_snapshots_commit_auto_distribution(self): """Test dch.py like gbp dch script does: new upstream version - two committed snapshots - do not set distribution""" options = ["--commit"] @@ -277,7 +260,6 @@ class TestScriptDch(DebianGitTestRepo): # But its changelog must be included in the new one self.assertIn(""" * TEST-COMMITTED-SNAPSHOT\n""", lines) - def test_dch_main_new_upstream_version_with_urgency(self): """Test dch.py like gbp dch script does: new upstream version - set urgency""" options = ["--urgency=emergency"] @@ -285,7 +267,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (1.0-1) UNRELEASED; urgency=emergency\n", lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_release_urgency(self): """Test dch.py like gbp dch script does: new upstream version - release - set urgency""" options = ["--release", "--urgency=emergency"] @@ -293,10 +274,9 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (1.0-1) %s; urgency=emergency\n" % os_codename, lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_new_upstream_version_with_snapshot_urgency(self): """Test dch.py like gbp dch script does: new upstream version - snapshot mode - set urgency""" - options = ["--snapshot", "--urgency=emergency"] + options = ["--snapshot", "--urgency=emergency"] lines = self.run_dch(options) header = re.search(snap_header_1, lines[0]) self.assertIsNotNone(header) @@ -304,7 +284,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version(self): """Test dch.py like gbp dch script does: increment debian version""" self.repo.delete_tag("debian/0.9-1") @@ -314,7 +293,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_release(self): """Test dch.py like gbp dch script does: increment debian version - release""" self.repo.delete_tag("upstream/1.0") @@ -323,7 +301,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_auto(self): """Test dch.py like gbp dch script does: increment debian version - guess last commit""" self.repo.delete_tag("upstream/1.0") @@ -332,7 +309,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertEqual("test-package (%s) UNRELEASED; urgency=%s\n" % (new_version_0_9, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_snapshot(self): """Test dch.py like gbp dch script does: increment debian version - snapshot mode""" self.repo.delete_tag("upstream/1.0") @@ -344,20 +320,18 @@ class TestScriptDch(DebianGitTestRepo): self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_auto_release(self): """Test dch.py like gbp dch script does: increment debian version - auto - release""" self.repo.delete_tag("upstream/1.0") - options = ["--auto", "--release"] + options = ["--auto", "--release"] lines = self.run_dch(options) self.assertEqual("test-package (%s) %s; urgency=%s\n" % (new_version_0_9, os_codename, default_urgency), lines[0]) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_increment_debian_version_with_auto_snapshot(self): """Test dch.py like gbp dch script does: increment debian version - auto - snapshot mode""" self.repo.delete_tag("upstream/1.0") - options = ["--auto", "--snapshot"] + options = ["--auto", "--snapshot"] lines = self.run_dch(options) header = re.search(snap_header_0_9, lines[0]) self.assertIsNotNone(header) @@ -365,7 +339,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertIsNotNone(re.search(snap_mark + header.group(1), lines[2])) self.assertIn(""" * added debian/control\n""", lines) - def test_dch_main_closes_default(self): options = ["--meta"] self.add_file("closes", "test file", @@ -374,7 +347,6 @@ class TestScriptDch(DebianGitTestRepo): self.assertIn(""" * test debian closes commit (Closes: #123456)\n""", lines) - def test_dch_main_closes_non_debian_bug_numbers(self): self.add_file("closes", "test file", msg="""test non-debian closes 1\n\nCloses: EX-123""") diff --git a/tests/23_test_dch_extract_bts_cmds.py b/tests/23_test_dch_extract_bts_cmds.py index 3acff5e6..bd4b0dbf 100644 --- a/tests/23_test_dch_extract_bts_cmds.py +++ b/tests/23_test_dch_extract_bts_cmds.py @@ -14,7 +14,6 @@ # """Test gbp.dch.extract_bts_cmds()""" -import os import unittest from gbp.dch import extract_bts_cmds diff --git a/tests/component/deb/__init__.py b/tests/component/deb/__init__.py index 8e91ce21..030a4823 100644 --- a/tests/component/deb/__init__.py +++ b/tests/component/deb/__init__.py @@ -24,9 +24,7 @@ from tests.component import ComponentTestGitRepository DEB_TEST_SUBMODULE = os.path.join('tests', 'component', 'deb', 'data') DEB_TEST_DATA_DIR = os.path.abspath(DEB_TEST_SUBMODULE) + def setup(): """Test Module setup""" ComponentTestGitRepository.check_testdata(DEB_TEST_SUBMODULE) - - - diff --git a/tests/component/deb/test_clone.py b/tests/component/deb/test_clone.py index dc7418ba..e953e2db 100644 --- a/tests/component/deb/test_clone.py +++ b/tests/component/deb/test_clone.py @@ -22,7 +22,7 @@ from tests.component import (ComponentTestBase, ComponentTestGitRepository) from tests.component.deb import DEB_TEST_DATA_DIR -from nose.tools import ok_, eq_ +from nose.tools import ok_ from gbp.scripts.import_dsc import main as import_dsc from gbp.scripts.clone import main as clone diff --git a/tests/component/deb/test_import_dsc.py b/tests/component/deb/test_import_dsc.py index 16a45b18..bc10962a 100644 --- a/tests/component/deb/test_import_dsc.py +++ b/tests/component/deb/test_import_dsc.py @@ -17,7 +17,6 @@ # import os -import hashlib from tests.component import (ComponentTestBase, ComponentTestGitRepository) diff --git a/tests/component/rpm/__init__.py b/tests/component/rpm/__init__.py index 52ab4b80..db776e38 100644 --- a/tests/component/rpm/__init__.py +++ b/tests/component/rpm/__init__.py @@ -16,16 +16,12 @@ # """Test module for RPM command line tools of the git-buildpackage suite""" -import six - from nose.tools import nottest import os import shutil from glob import glob -from xml.dom import minidom from gbp.command_wrappers import Command -from gbp.git import GitRepositoryError from tests.component import ComponentTestBase, ComponentTestGitRepository @@ -33,10 +29,12 @@ from tests.component import ComponentTestBase, ComponentTestGitRepository RPM_TEST_DATA_SUBMODULE = os.path.join('tests', 'component', 'rpm', 'data') RPM_TEST_DATA_DIR = os.path.abspath(RPM_TEST_DATA_SUBMODULE) + def setup(): """Test Module setup""" ComponentTestGitRepository.check_testdata(RPM_TEST_DATA_SUBMODULE) + class RpmRepoTestBase(ComponentTestBase): """Baseclass for tests run in a Git repository with packaging data""" diff --git a/tests/test_Config.py b/tests/test_Config.py index 1db2ad3a..495862c7 100644 --- a/tests/test_Config.py +++ b/tests/test_Config.py @@ -5,7 +5,8 @@ Test L{gbp.config.GbpOptionParser} Test L{gbp.config.GbpOptionParserDebian} """ -from . import context +from . import context # noqa: F401 + def test_option_parser(): """ @@ -20,6 +21,7 @@ def test_option_parser(): >>> c.add_boolean_config_file_option(option_name='track', dest='track') """ + def test_option_parser_debian(): """ Methods tested: @@ -34,6 +36,7 @@ def test_option_parser_debian(): >>> c.add_config_file_option(option_name='builder', dest='builder', help='foo') """ + def test_option_group(): """ Methods tested: @@ -47,11 +50,12 @@ def test_option_group(): >>> g.add_boolean_config_file_option(option_name='track', dest='track') """ + def test_tristate(): """ Methods tested: - L{gbp.config.GbpOptionParser.add_config_file_option} - + >>> import gbp.config >>> c = gbp.config.GbpOptionParser('tristate') >>> c.add_config_file_option(option_name="color", dest="color", type='tristate') @@ -60,6 +64,7 @@ def test_tristate(): auto """ + def test_filter(): """ The filter option should always parse as a list @@ -81,6 +86,7 @@ def test_filter(): >>> del os.environ['GBP_CONF_FILES'] """ + def test_filters(): """ The filter can be given in plural form diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py index 1b59dd2c..5545cd05 100644 --- a/tests/test_GitRepository.py +++ b/tests/test_GitRepository.py @@ -116,6 +116,7 @@ def test_branch_master(): 'master' """ + def test_clean(): """ Remove untracked files from the working tree @@ -135,6 +136,7 @@ def test_clean(): True """ + def test_create_branch(): """ Create a branch name I{foo} @@ -152,6 +154,7 @@ def test_create_branch(): False """ + def test_delete_branch(): """ Create a branch named I{foo2} and delete it @@ -170,6 +173,7 @@ def test_delete_branch(): GitRepositoryError: Can't delete the branch you're on """ + def test_set_branch(): """ Switch to branch named I{foo} @@ -228,6 +232,7 @@ def test_set_upstream_branch(): GitRepositoryError: Branch origin/bla doesn't exist! """ + def test_get_upstream_branch(): """ Get info about upstream branches set in test_set_upstream_branch @@ -243,6 +248,7 @@ def test_get_upstream_branch(): GitRepositoryError: Branch bla doesn't exist! """ + def test_tag(): """ Create a tag named I{tag} and check its existance @@ -271,6 +277,7 @@ def test_tag(): ['tag', 'tag2'] """ + def test_describe(): """ Describe commit-ish @@ -304,6 +311,7 @@ def test_describe(): >>> repo.create_tag('tag2', msg='foo') """ + def test_find_tag(): """ Find tags @@ -321,6 +329,7 @@ def test_find_tag(): GitRepositoryError: Can't describe HEAD. Git error: fatal: No names found, cannot describe anything. """ + def test_find_branch_tag(): """ Find the closest tags on a certain branch to a given commit @@ -338,6 +347,7 @@ def test_find_branch_tag(): GitRepositoryError: Can't describe .... Git error: fatal: No names found, cannot describe anything. """ + def test_move_tag(): """ Move a tag @@ -355,6 +365,7 @@ def test_move_tag(): True """ + def test_delete_tag(): """ Delete tags @@ -372,6 +383,7 @@ def test_delete_tag(): False """ + def test_get_obj_type(): """ Find commit SHA1 related to tags @@ -393,6 +405,7 @@ def test_get_obj_type(): >>> repo.delete_tag("tag3") """ + def test_list_files(): """ List files in the index @@ -438,6 +451,7 @@ def test_list_files(): [] """ + def test_get_commits(): """ Test listing commits @@ -503,6 +517,7 @@ def test_get_commit_info(): 'foo' """ + def test_diff(): """ Test git-diff @@ -524,6 +539,7 @@ def test_diff(): True """ + def test_diff_status(): """ Methods tested: @@ -537,6 +553,7 @@ def test_diff_status(): defaultdict(<... 'list'>, {'M': ['testfile']}) """ + def test_mirror_clone(): """ Mirror a repository @@ -566,6 +583,7 @@ def test_mirror_clone(): >>> mirror.force_head('foo^') """ + def test_clone(): """ Clone a repository @@ -612,6 +630,7 @@ def test_clone(): False """ + def test_get_remotes(): """ Merge a branch @@ -634,6 +653,7 @@ def test_get_remotes(): True """ + def test_merge(): """ Merge a branch @@ -648,6 +668,7 @@ def test_merge(): >>> repo.merge('foo') """ + def test_pull(): """ Pull from a remote repository @@ -665,6 +686,7 @@ def test_pull(): >>> clone.pull('origin', all_remotes=True) """ + def test_fetch(): """ Fetch from a remote repository @@ -696,6 +718,7 @@ def test_fetch(): >>> clone.remove_remote_repo('foo') """ + def test_create_bare(): """ Create a bare repository @@ -718,6 +741,7 @@ def test_create_bare(): (True, '') """ + def test_nonexistent(): """ Check that accessing a non-existent repository fails. @@ -732,6 +756,7 @@ def test_nonexistent(): GitRepositoryError: No Git repository at '/does/not/exist' """ + def test_create_noperm(): """ Check that creating a repository at a path that isn't writeable fails @@ -746,6 +771,7 @@ def test_create_noperm(): GitRepositoryError: Cannot create Git repository at '/does/not/exist': Permission denied """ + def test_checkout(): """ Checkout treeishs @@ -786,6 +812,7 @@ def test_checkout(): >>> repo.branch """ + def test_gc(): """ Test garbace collection @@ -798,6 +825,7 @@ def test_gc(): >>> repo.collect_garbage() """ + def test_grep_log(): """ Test grepping through commit messages @@ -820,6 +848,7 @@ def test_grep_log(): GitRepositoryError: Error grepping log for foo: fatal: bad revision 'doesnotexist' """ + def test_is_ff(): """ Test if branch is fast forwardable @@ -838,6 +867,7 @@ def test_is_ff(): (False, True) """ + def test_update_ref(): """ Test updating a reference @@ -894,6 +924,7 @@ def test_update_submodules(): >>> repo.update_submodules() """ + def test_get_merge_base(): """ Find the common ancestor of two objects @@ -912,6 +943,7 @@ def test_get_merge_base(): GitRepositoryError: Failed to get common ancestor: fatal: Not a valid object name doesnotexist """ + def test_status(): r""" Methods tested: @@ -934,6 +966,7 @@ def test_status(): [('R ', ['test_status\x00test_statusnew'])] """ + def test_cmd_has_feature(): r""" Methods tested: diff --git a/tests/test_GitVfs.py b/tests/test_GitVfs.py index a88282f0..df8c042b 100644 --- a/tests/test_GitVfs.py +++ b/tests/test_GitVfs.py @@ -6,10 +6,11 @@ Test L{gbp.git.GitVfs} import gbp.log -from . import context +from . import context # noqa: F401 gbp.log.setup(color=False, verbose=True) + def test_read(): """ Create a repository diff --git a/tests/testutils/__init__.py b/tests/testutils/__init__.py index 60765af4..cc5e4cb4 100644 --- a/tests/testutils/__init__.py +++ b/tests/testutils/__init__.py @@ -1,6 +1,6 @@ # vim: set fileencoding=utf-8 : -from .. import context +from .. import context # noqa: F401 import os import shutil @@ -21,6 +21,7 @@ __all__ = ['GbpLogTester', 'DebianGitTestRepo', 'OsReleaseFile', 'MockedChangeLog', 'get_dch_default_urgency', 'capture_stderr', 'ls_dir', 'ls_tar', 'ls_zip'] + class OsReleaseFile(object): """Repesents a simple file with key-value pairs""" @@ -38,7 +39,7 @@ class OsReleaseFile(object): self._values[key] = value.strip() except IOError as err: gbp.log.info('Failed to read OS release file %s: %s' % - (filename, err)) + (filename, err)) def __getitem__(self, key): if key in self._values: @@ -54,6 +55,7 @@ class OsReleaseFile(object): def __repr__(self): return repr(self._values) + class MockedChangeLog(ChangeLog): contents = """foo (%s) experimental; urgency=low @@ -61,7 +63,7 @@ class MockedChangeLog(ChangeLog): -- Debian Maintainer Sat, 01 Jan 2012 00:00:00 +0100""" - def __init__(self, version, changes = "a important change"): + def __init__(self, version, changes="a important change"): ChangeLog.__init__(self, contents=self.contents % (version, changes)) @@ -101,6 +103,7 @@ def ls_dir(directory, directories=True): contents.update(['%s%s' % (prefix, dname) for dname in dirs]) return contents + def ls_tar(tarball, directories=True): """List the contents of tar archive""" tmpdir = tempfile.mkdtemp() @@ -111,6 +114,7 @@ def ls_tar(tarball, directories=True): finally: shutil.rmtree(tmpdir) + def ls_zip(archive, directories=True): """List the contents of zip file""" tmpdir = tempfile.mkdtemp() @@ -120,4 +124,3 @@ def ls_zip(archive, directories=True): return ls_dir(tmpdir, directories) finally: shutil.rmtree(tmpdir) - diff --git a/tests/testutils/debiangittestrepo.py b/tests/testutils/debiangittestrepo.py index 09bf8a70..9a9ee07d 100644 --- a/tests/testutils/debiangittestrepo.py +++ b/tests/testutils/debiangittestrepo.py @@ -7,6 +7,7 @@ import unittest import gbp.deb.git + class DebianGitTestRepo(unittest.TestCase): """Scratch repo for a single unit test""" @@ -39,6 +40,6 @@ class DebianGitTestRepo(unittest.TestCase): os.makedirs(d) with open(path, 'w+') as f: - content == None or f.write(content) + content is None or f.write(content) self.repo.add_files(name, force=True) self.repo.commit_files(path, msg or "added %s" % name) diff --git a/tests/testutils/gbplogtester.py b/tests/testutils/gbplogtester.py index 3b4e92ea..6bb173f4 100644 --- a/tests/testutils/gbplogtester.py +++ b/tests/testutils/gbplogtester.py @@ -6,6 +6,7 @@ from nose.tools import ok_, assert_less import gbp.log + class GbpLogTester(object): """ Helper class for tests that need to capture logging output -- cgit v1.2.3