From patchwork Wed May 11 09:47:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Lo=C3=AFc_Minier?= X-Patchwork-Id: 1450 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:52:04 -0000 Delivered-To: patches@linaro.org Received: by 10.224.61.3 with SMTP id r3cs54226qah; Wed, 11 May 2011 02:47:17 -0700 (PDT) Received: by 10.213.107.139 with SMTP id b11mr3273816ebp.93.1305107236886; Wed, 11 May 2011 02:47:16 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id o22si21205438wen.197.2011.05.11.02.47.16; Wed, 11 May 2011 02:47:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QK60i-0007Wt-9M for ; Wed, 11 May 2011 09:47:16 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 43AEC2E802E for ; Wed, 11 May 2011 09:47:16 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 338 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 338: Merge lp:~lool/linaro-image-tools/pyflakes-fixes-of-the-day; fixes some Message-Id: <20110511094716.11377.68611.launchpad@loganberry.canonical.com> Date: Wed, 11 May 2011 09:47:16 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13014"; Instance="initZopeless config overlay" X-Launchpad-Hash: 38137183fee0fb5bc3b14070cbb4d059fc91b993 Merge authors: Loïc Minier (lool) Loïc Minier (lool) Related merge proposals: https://code.launchpad.net/~lool/linaro-image-tools/pyflakes-fixes-of-the-day/+merge/60522 proposed by: Loïc Minier (lool) review: Approve - Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 338 [merge] committer: Loïc Minier branch nick: linaro-image-tools timestamp: Wed 2011-05-11 11:44:06 +0200 message: Merge lp:~lool/linaro-image-tools/pyflakes-fixes-of-the-day; fixes some warnings reported by pyflakes and run pyflakes as part of the testsuite if available. added: linaro_image_tools/tests/test_pyflakes.py modified: linaro_image_tools/hwpack/packages.py linaro_image_tools/hwpack/tests/test_config.py linaro_image_tools/media_create/tests/test_media_create.py linaro_image_tools/tests/__init__.py linaro_image_tools/utils.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_image_tools/hwpack/packages.py' --- linaro_image_tools/hwpack/packages.py 2011-04-06 07:28:59 +0000 +++ linaro_image_tools/hwpack/packages.py 2011-05-10 15:06:52 +0000 @@ -193,7 +193,7 @@ with open(os.path.join(tmpdir, 'Packages'), 'w') as packages_file: packages_file.write(get_packages_file(local_debs, rel_to=tmpdir)) if label: - proc = cmd_runner.run( + cmd_runner.run( ['apt-ftparchive', '-oAPT::FTPArchive::Release::Label=%s' % label, 'release', === modified file 'linaro_image_tools/hwpack/tests/test_config.py' --- linaro_image_tools/hwpack/tests/test_config.py 2011-03-23 22:25:10 +0000 +++ linaro_image_tools/hwpack/tests/test_config.py 2011-05-10 15:09:20 +0000 @@ -33,6 +33,7 @@ def test_create(self): config = Config(StringIO()) + self.assertTrue(config is not None) def get_config(self, contents): return Config(StringIO(contents)) === modified file 'linaro_image_tools/media_create/tests/test_media_create.py' --- linaro_image_tools/media_create/tests/test_media_create.py 2011-05-06 13:29:10 +0000 +++ linaro_image_tools/media_create/tests/test_media_create.py 2011-05-10 15:05:57 +0000 @@ -628,6 +628,8 @@ file1 = self.createTempFileAsFixture(prefix) file2 = self.createTempFileAsFixture(prefix) directory = os.path.dirname(file1) + assert directory == os.path.dirname(file2), ( + "file1 and file2 should be in the same directory") self.assertRaises( ValueError, _get_file_matching, '%s/%s*' % (directory, prefix)) === modified file 'linaro_image_tools/tests/__init__.py' --- linaro_image_tools/tests/__init__.py 2011-03-24 10:18:09 +0000 +++ linaro_image_tools/tests/__init__.py 2011-05-10 15:43:32 +0000 @@ -1,15 +1,21 @@ +import os import unittest from linaro_image_tools.hwpack.tests import test_suite as hwpack_suite from linaro_image_tools.media_create.tests import ( test_suite as media_create_suite, ) +from linaro_image_tools.utils import has_command def test_suite(): module_names = [ 'linaro_image_tools.tests.test_cmd_runner', 'linaro_image_tools.tests.test_utils', ] + # if pyflakes is installed and we're running from a bzr checkout... + if has_command('pyflakes') and not os.path.isabs(__file__): + # ...also run the pyflakes tests + module_names.append('linaro_image_tools.tests.test_pyflakes') loader = unittest.TestLoader() suite = loader.loadTestsFromNames(module_names) suite.addTests(hwpack_suite()) === added file 'linaro_image_tools/tests/test_pyflakes.py' --- linaro_image_tools/tests/test_pyflakes.py 1970-01-01 00:00:00 +0000 +++ linaro_image_tools/tests/test_pyflakes.py 2011-05-10 15:43:32 +0000 @@ -0,0 +1,36 @@ +# Copyright (C) 2011 Linaro +# +# Author: Loic Minier +# +# This file is part of Linaro Image Tools. +# +# Linaro Image Tools is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Linaro Image Tools is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +import subprocess +from testtools import TestCase + +class TestPyflakes(TestCase): + def test_pyflakes(self): + # ignore return code + proc = subprocess.Popen(['pyflakes', '.'], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + (stdout, stderr) = proc.communicate() + stdout = stdout.splitlines() + stdout.sort() + expected = ["./linaro_image_tools/utils.py:26: redefinition of " + "unused 'CommandNotFound' from line 24" ] + self.assertEquals(expected, stdout) + self.assertEquals('', stderr) + === modified file 'linaro_image_tools/utils.py' --- linaro_image_tools/utils.py 2011-03-24 21:47:55 +0000 +++ linaro_image_tools/utils.py 2011-05-10 15:42:59 +0000 @@ -52,15 +52,21 @@ ['apt-get', '--yes', 'install', package], as_root=True).wait() -def ensure_command(command): - """Ensure the given command is available. - - If it's not, look up a package that provides it and install that. - """ +def has_command(command): + """Check the given command is available.""" try: cmd_runner.run( ['which', command], stdout=open('/dev/null', 'w')).wait() + return True except cmd_runner.SubcommandNonZeroReturnValue: + return False + +def ensure_command(command): + """Ensure the given command is available. + + If it's not, look up a package that provides it and install that. + """ + if not has_command(command): install_package_providing(command) def find_command(name, prefer_dir=None):