aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTommi Virtanen <tv@eagain.net>2007-09-01 16:36:01 -0700
committerTommi Virtanen <tv@eagain.net>2007-09-01 16:44:28 -0700
commitfd11351859233727538fa47213df7c7c9821d9e0 (patch)
tree9f38ba2a57cb3c8099641d0293aa8a672fe6b5c5
parentMake sure re-initing a repository does not change access modes. (diff)
downloadgitosis-dakkar-fd11351859233727538fa47213df7c7c9821d9e0.tar.gz
gitosis-dakkar-fd11351859233727538fa47213df7c7c9821d9e0.tar.bz2
gitosis-dakkar-fd11351859233727538fa47213df7c7c9821d9e0.zip
Use separate temp directories for separate tests.
Makes unit tests for the previous commit work even when not run alone. Should have done this from the beginning, but didn't find the trick for getting the module name.
-rw-r--r--gitosis/test/test_repository.py3
-rw-r--r--gitosis/test/util.py20
2 files changed, 17 insertions, 6 deletions
diff --git a/gitosis/test/test_repository.py b/gitosis/test/test_repository.py
index 2ac0d79..c9fbc58 100644
--- a/gitosis/test/test_repository.py
+++ b/gitosis/test/test_repository.py
@@ -1,7 +1,6 @@
from nose.tools import eq_ as eq
import os
-import shutil
from gitosis import repository
@@ -39,8 +38,6 @@ def test_init_exist_git():
def test_init_templates():
tmp = maketemp()
path = os.path.join(tmp, 'repo.git')
- if os.path.exists(path):
- shutil.rmtree(path)
templatedir = os.path.join(
os.path.dirname(__file__),
'mocktemplates',
diff --git a/gitosis/test/util.py b/gitosis/test/util.py
index b37178e..aa5a4a2 100644
--- a/gitosis/test/util.py
+++ b/gitosis/test/util.py
@@ -2,7 +2,9 @@ from nose.tools import eq_ as eq
import errno
import os
+import shutil
import stat
+import sys
def mkdir(*a, **kw):
try:
@@ -16,9 +18,21 @@ def mkdir(*a, **kw):
def maketemp():
tmp = os.path.join(os.path.dirname(__file__), 'tmp')
mkdir(tmp)
- me = os.path.splitext(os.path.basename(__file__))[0]
- tmp = os.path.join(tmp, me)
- mkdir(tmp)
+
+ caller = sys._getframe(1)
+ name = '%s.%s' % (
+ sys._getframe(1).f_globals['__name__'],
+ caller.f_code.co_name,
+ )
+ tmp = os.path.join(tmp, name)
+ try:
+ shutil.rmtree(tmp)
+ except OSError, e:
+ if e.errno == errno.ENOENT:
+ pass
+ else:
+ raise
+ os.mkdir(tmp)
return tmp
def writeFile(path, content):