aboutsummaryrefslogtreecommitdiff
path: root/tests/02_import.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/02_import.py')
-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 0000000..d31533f
--- /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\:·: