From f1f3d8e42f8ba94482957a6110c027cedac6055e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 24 Dec 2009 23:20:12 +0100 Subject: Add unpack test --- tests/02_import.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/02_import.py (limited to 'tests') 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\:·: -- cgit v1.2.3