aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/02_test_upstream_source_tar_unpack.py
diff options
context:
space:
mode:
authorThomas Koch <thomas@koch.ro>2013-01-21 15:50:39 +0100
committerGuido Günther <agx@sigxcpu.org>2013-04-08 07:43:02 +0200
commit3d6b68ae541d6020ff747628b3e44196999e0a50 (patch)
treebb3f94d4f9c0af6eb3a9779dbf6bbee20a512ef0 /tests/02_test_upstream_source_tar_unpack.py
parent92edb4eda14cf4b5fd1514feb7b81aa50456285c (diff)
tests: Use tempfile.mkdtemp to create temp dirs for tests
This puts test dirs below /tmp which often is a tmpfs. All tests include the context module which consolidates tmpdir creation and cleanup, undoes a chdir in teardown and silences log messages.
Diffstat (limited to 'tests/02_test_upstream_source_tar_unpack.py')
-rw-r--r--tests/02_test_upstream_source_tar_unpack.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/tests/02_test_upstream_source_tar_unpack.py b/tests/02_test_upstream_source_tar_unpack.py
index 650dc2ae..97bf76bb 100644
--- a/tests/02_test_upstream_source_tar_unpack.py
+++ b/tests/02_test_upstream_source_tar_unpack.py
@@ -2,14 +2,17 @@
"""Test L{UpstreamSource}'s tarball unpack"""
+from . import context
+
import os
import shutil
import tarfile
import tempfile
+import unittest
-import gbp.deb
+import gbp.pkg
-class TestUnpack:
+class TestUnpack(unittest.TestCase):
"""Make sure we unpack gzip and bzip2 archives correctly"""
archive_prefix = "archive"
@@ -34,17 +37,15 @@ class TestUnpack:
return name, filelist
def setUp(self):
- self.dir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
- self.top = os.path.abspath(os.curdir)
- os.chdir(self.dir)
+ self.dir = context.new_tmpdir(__name__)
+ self.top = context.projectdir
+ context.chdir(self.dir)
self.archives = {}
for ext in [ "gz", "bz2" ]:
self.archives[ext] = self._create_archive(ext)
def tearDown(self):
- os.chdir(self.top)
- if not os.getenv("GBP_TESTS_NOCLEAN"):
- shutil.rmtree(self.dir)
+ context.teardown()
def test_upstream_source_type(self):
for (comp, archive) in self.archives.iteritems():