=== modified file 'linaro_image_tools/hwpack/packages.py'
@@ -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'
@@ -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'
@@ -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'
@@ -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'
@@ -0,0 +1,36 @@
+# Copyright (C) 2011 Linaro
+#
+# Author: Loic Minier <loic.minier@linaro.org>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+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'
@@ -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):