aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2009-12-24 23:20:12 +0100
committerGuido Günther <agx@sigxcpu.org>2009-12-24 23:34:10 +0100
commitf1f3d8e42f8ba94482957a6110c027cedac6055e (patch)
treeaf1c1b54b5214dc2edb0a3b9e48d4ffeef66f9ab
parent7ad35fb9432f1206c1ae338c4052810ecabb9420 (diff)
Add unpack test
-rw-r--r--tests/02_import.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/02_import.py b/tests/02_import.py
new file mode 100644
index 00000000..d31533f0
--- /dev/null
+++ b/tests/02_import.py
@@ -0,0 +1,41 @@
+# vim: set fileencoding=utf-8 :
+
+import glob
+import os
+import shutil
+import tarfile
+import tempfile
+
+import gbp.deb
+
+class TestUnpack:
+ """Make sure we unpack gzip and bzip2 archives correctly"""
+ def _createArchive(self, comp):
+ archive = "archive"
+ name = "%s_0.1.tar.%s" % (archive, comp)
+ t = tarfile.open(name= name, mode='w:%s' % comp)
+ for f in glob.glob(os.path.join(self.top, "*.py")):
+ t.add(os.path.join(self.top,f),
+ os.path.join("%s-%s" % (archive, comp),
+ os.path.basename(f)))
+ t.close()
+ return name
+
+ def setUp(self):
+ self.dir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
+ self.top = os.path.abspath(os.curdir)
+ os.chdir(self.dir)
+ self.archives = {}
+ for ext in [ "gz", "bz2" ]:
+ self.archives[ext] = self._createArchive(ext)
+
+ def tearDown(self):
+ os.chdir(self.top)
+ if not os.getenv("GBP_TESTS_NOCLEAN"):
+ shutil.rmtree(self.dir)
+
+ def testUnpack(self):
+ for (comp, archive) in self.archives.iteritems():
+ gbp.deb.unpack_orig(archive, ".", [])
+
+# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: