diff options
author | Guido Günther <agx@sigxcpu.org> | 2014-03-27 20:42:29 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-03-27 20:42:29 +0100 |
commit | fd440e204a6ebf62d65ff564db8c1aaa262472d2 (patch) | |
tree | 025404905c0afb31c0e1bc3c3414fc8f30a502dd | |
parent | 15d87fb04cba371885d57bb6fd899f79380f1c2e (diff) |
Use a temporary directory
This avoids file name collisions and weired files in the working copy.
-rw-r--r-- | tests/testutils.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tests/testutils.py b/tests/testutils.py index d04f5fe9..e161dbe5 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -3,7 +3,9 @@ from . import context import os +import shutil import subprocess +import tempfile import unittest import gbp.log @@ -91,8 +93,9 @@ class MockedChangeLog(ChangeLog): def get_dch_default_urgency(): """Determine the default urgency level used by dch""" - urgency='medium' - tmp_dch_name = '__test_dch' + urgency = 'medium' + tempdir = tempfile.mkdtemp() + tmp_dch_name = os.path.join(tempdir, 'changelog') try: dch_cmd = ['dch', '--create', '--empty', '--changelog', tmp_dch_name, '--package=foo', '--newversion=1', @@ -106,7 +109,7 @@ def get_dch_default_urgency(): header = dchfile.readline().strip() urgency = header.split()[-1].replace('urgency=', '') finally: - if os.path.isfile(tmp_dch_name): - os.unlink(tmp_dch_name) + if os.path.isdir(tempdir): + shutil.rmtree(tempdir) return urgency |