aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_GitRepository.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/test_GitRepository.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/test_GitRepository.py')
-rw-r--r--tests/test_GitRepository.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/tests/test_GitRepository.py b/tests/test_GitRepository.py
index e7dde0dc..a91ee060 100644
--- a/tests/test_GitRepository.py
+++ b/tests/test_GitRepository.py
@@ -11,20 +11,16 @@ This testcase creates several repositores:
- A mirror of I{repo} below L{mirror_clone_dir} called I{mirror}
"""
+from . import context
+
import os
import gbp.log
gbp.log.setup(color=False, verbose=True)
-repo_dir = os.path.abspath(
- os.path.join(os.path.curdir, 'gbp_%s_test_repo' % __name__))
-bare_dir = os.path.abspath(
- os.path.join(os.path.curdir, 'gbp_%s_test_bare' % __name__))
-clone_dir = os.path.abspath(
- os.path.join(os.path.curdir, 'gbp_%s_test_clone' % __name__))
-mirror_clone_dir = os.path.abspath(
- os.path.join(os.path.curdir, 'gbp_%s_test_mirror_clone' % __name__))
-
+repo_dir, bare_dir, clone_dir, mirror_clone_dir = map(
+ lambda x, tmpdir=context.new_tmpdir(__name__): tmpdir.join(x),
+ ['repo', 'bare', 'clone', 'mirror_clone'])
def test_create():
"""
@@ -539,7 +535,7 @@ def test_pull():
- L{gbp.git.GitRepository.pull}
>>> import gbp.git, os
- >>> d = os.path.join(clone_dir, 'gbp_%s_test_repo' % __name__)
+ >>> d = os.path.join(clone_dir, 'repo')
>>> clone = gbp.git.GitRepository(d)
>>> clone.set_branch('master')
>>> clone.pull()
@@ -557,7 +553,7 @@ def test_fetch():
- L{gbp.git.GitRepository.remove_remote_repo}
>>> import gbp.git, os
- >>> d = os.path.join(clone_dir, 'gbp_%s_test_repo' % __name__)
+ >>> d = os.path.join(clone_dir, 'repo')
>>> clone = gbp.git.GitRepository(d)
>>> clone.fetch()
>>> clone.push()
@@ -817,11 +813,7 @@ def test_teardown():
"""
Perform the teardown
- >>> import shutil, os
- >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(repo_dir)
- >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(bare_dir)
- >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(mirror_clone_dir)
- >>> os.getenv("GBP_TESTS_NOCLEAN") or shutil.rmtree(clone_dir)
+ >>> context.teardown()
"""
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: