diff mbox

[Branch,~linaro-image-tools/linaro-image-tools/trunk] Rev 412: Fixes three problems shown by unit tests:

Message ID 20110818203017.16186.43569.launchpad@ackee.canonical.com
State Accepted
Headers show

Commit Message

James Tunnicliffe Aug. 18, 2011, 8:30 p.m. UTC
Merge authors:
  James Tunnicliffe (dooferlad)
Related merge proposals:
  https://code.launchpad.net/~dooferlad/linaro-image-tools/unit_test_fixes/+merge/72062
  proposed by: James Tunnicliffe (dooferlad)
  review: Approve - James Westby (james-w)
------------------------------------------------------------
revno: 412 [merge]
committer: James Tunnicliffe <james.tunnicliffe@linaro.org>
branch nick: linaro-image-tools
timestamp: Thu 2011-08-18 21:29:15 +0100
message:
  Fixes three problems shown by unit tests:
   * Assert always runs - changed to raise AssertionError
   * Updated test_pyflakes.py so the "redefinition of unused CommandNotFound" error is ignored again
   * Test test_verify_files now passes (NamedTemporaryFile mocked to be predicatable)
modified:
  linaro_image_tools/fetch_image.py
  linaro_image_tools/tests/test_pyflakes.py
  linaro_image_tools/tests/test_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
diff mbox

Patch

=== modified file 'linaro_image_tools/fetch_image.py'
--- linaro_image_tools/fetch_image.py	2011-08-18 14:58:29 +0000
+++ linaro_image_tools/fetch_image.py	2011-08-18 16:00:26 +0000
@@ -1476,8 +1476,9 @@ 
                              ("platform", args['platform'])])
 
         else:
-            assert(0, "Unexpected args['release_or_snapshot']: {0}".format(
-                       args['release_or_snapshot']))
+            message = "Unexpected args['release_or_snapshot']: {0}".format(
+                       args['release_or_snapshot'])
+            raise AssertionError(message)
 
         if(not image_url):
             # If didn't get an image URL set up something so the return line

=== modified file 'linaro_image_tools/tests/test_pyflakes.py'
--- linaro_image_tools/tests/test_pyflakes.py	2011-07-28 10:44:05 +0000
+++ linaro_image_tools/tests/test_pyflakes.py	2011-08-18 16:00:26 +0000
@@ -29,8 +29,8 @@ 
         (stdout, stderr) = proc.communicate()
         stdout = stdout.splitlines()
         stdout.sort()
-        expected = ["./linaro_image_tools/utils.py:29: redefinition of "
-                        "unused 'CommandNotFound' from line 27" ]
+        expected = ["./linaro_image_tools/utils.py:30: redefinition of "
+                        "unused 'CommandNotFound' from line 28" ]
         self.assertEquals(expected, stdout)
         self.assertEquals('', stderr)
 

=== modified file 'linaro_image_tools/tests/test_utils.py'
--- linaro_image_tools/tests/test_utils.py	2011-08-15 11:09:36 +0000
+++ linaro_image_tools/tests/test_utils.py	2011-08-18 16:00:26 +0000
@@ -22,6 +22,7 @@ 
 import subprocess
 import sys
 import logging
+import tempfile
 
 from linaro_image_tools import cmd_runner, utils
 from linaro_image_tools.testing import TestCaseWithFixtures
@@ -91,14 +92,25 @@ 
                 TestVerifyFileIntegrity.filenames_in_shafile) + ': OK\n'
             raise cmd_runner.SubcommandNonZeroReturnValue([], 1, stdout, None)
 
+    class FakeTempFile():
+        name = "/tmp/1"
+
+        def close(self):
+            pass
+
+        def read(self):
+            return ""
 
     def test_verify_files(self):
         fixture = self.useFixture(MockCmdRunnerPopenFixture())
+        self.useFixture(MockSomethingFixture(tempfile, 'NamedTemporaryFile',
+                                             self.FakeTempFile))
         hash_filename = "dummy-file.txt"
         signature_filename = hash_filename + ".asc"
         verify_file_integrity([signature_filename])
         self.assertEqual(
-            ['gpg --verify %s' % signature_filename,
+            ['gpg --status-file=%s --verify %s' % (self.FakeTempFile.name,
+                                                   signature_filename),
              'sha1sum -c %s' % hash_filename],
             fixture.mock.commands_executed)