[Pkg-bazaar-commits] r122 ./bzr-builddeb/people/jdw/merge_upstream: Raise an error on trying to repack an unkown format.

James Westby jw+debian at jameswestby.net
Sat Jun 23 18:15:14 UTC 2007


------------------------------------------------------------
revno: 122
committer: James Westby <jw+debian at jameswestby.net>
branch nick: merge_upstream
timestamp: Sat 2007-06-23 19:15:14 +0100
message:
  Raise an error on trying to repack an unkown format.
added:
  tests/test_repack_tarball_extra.py
modified:
  repack_tarball.py
  tests/__init__.py
-------------- next part --------------
=== added file 'tests/test_repack_tarball_extra.py'
--- a/tests/test_repack_tarball_extra.py	1970-01-01 00:00:00 +0000
+++ b/tests/test_repack_tarball_extra.py	2007-06-23 18:15:14 +0000
@@ -0,0 +1,36 @@
+#    test_repack_tarball_extra.py -- Extra tests for repacking tarballs
+#    Copyright (C) 2007 James Westby <jw+debian at jameswestby.net>
+#
+#    This file is part of bzr-builddeb.
+#
+#    bzr-builddeb 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 2 of the License, or
+#    (at your option) any later version.
+#
+#    bzr-builddeb 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 bzr-builddeb; if not, write to the Free Software
+#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+from repack_tarball import repack_tarball
+
+from bzrlib.errors import BzrCommandError
+from bzrlib.tests import TestCaseInTempDir
+
+
+class TestRepackTarballExtra(TestCaseInTempDir):
+
+  def test_repack_tarball_errors_unkown_format(self):
+    old_tarball = 'package-0.2.INVALID'
+    f = open(old_tarball, 'w')
+    f.close()
+    self.failUnlessExists(old_tarball)
+    self.assertRaises(BzrCommandError, repack_tarball, old_tarball,
+                      'package_0.2.orig.tar.gz')
+

=== modified file 'repack_tarball.py'
--- a/repack_tarball.py	2007-06-23 10:31:23 +0000
+++ b/repack_tarball.py	2007-06-23 18:15:14 +0000
@@ -26,6 +26,7 @@
 
 from bzrlib.errors import (NoSuchFile,
                            FileExists,
+                           BzrCommandError,
                            )
 
 
@@ -79,6 +80,7 @@
           new_tar.close()
       finally:
         old_tar.close()
+    else:
+      raise BzrCommandError('Unsupported format for repack: %s' % orig_name)
   # TODO: handle zip files.
-  # TODO: complain on unrecognised formats and test for that.
 

=== modified file 'tests/__init__.py'
--- a/tests/__init__.py	2007-06-23 10:31:23 +0000
+++ b/tests/__init__.py	2007-06-23 18:15:14 +0000
@@ -135,6 +135,7 @@
     testmod_names = [
             'test_builder',
             'test_config',
+            'test_repack_tarball_extra',
             'test_util',
             ]
     suite.addTest(loader.loadTestsFromModuleNames(["%s.%s" % (__name__, i)



More information about the Pkg-bazaar-commits mailing list