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.
This commit is contained in:
parent
0132515356
commit
fd11351859
|
@ -1,7 +1,6 @@
|
||||||
from nose.tools import eq_ as eq
|
from nose.tools import eq_ as eq
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
|
|
||||||
from gitosis import repository
|
from gitosis import repository
|
||||||
|
|
||||||
|
@ -39,8 +38,6 @@ def test_init_exist_git():
|
||||||
def test_init_templates():
|
def test_init_templates():
|
||||||
tmp = maketemp()
|
tmp = maketemp()
|
||||||
path = os.path.join(tmp, 'repo.git')
|
path = os.path.join(tmp, 'repo.git')
|
||||||
if os.path.exists(path):
|
|
||||||
shutil.rmtree(path)
|
|
||||||
templatedir = os.path.join(
|
templatedir = os.path.join(
|
||||||
os.path.dirname(__file__),
|
os.path.dirname(__file__),
|
||||||
'mocktemplates',
|
'mocktemplates',
|
||||||
|
|
|
@ -2,7 +2,9 @@ from nose.tools import eq_ as eq
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
import stat
|
import stat
|
||||||
|
import sys
|
||||||
|
|
||||||
def mkdir(*a, **kw):
|
def mkdir(*a, **kw):
|
||||||
try:
|
try:
|
||||||
|
@ -16,9 +18,21 @@ def mkdir(*a, **kw):
|
||||||
def maketemp():
|
def maketemp():
|
||||||
tmp = os.path.join(os.path.dirname(__file__), 'tmp')
|
tmp = os.path.join(os.path.dirname(__file__), 'tmp')
|
||||||
mkdir(tmp)
|
mkdir(tmp)
|
||||||
me = os.path.splitext(os.path.basename(__file__))[0]
|
|
||||||
tmp = os.path.join(tmp, me)
|
caller = sys._getframe(1)
|
||||||
mkdir(tmp)
|
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
|
return tmp
|
||||||
|
|
||||||
def writeFile(path, content):
|
def writeFile(path, content):
|
||||||
|
|
Loading…
Reference in a new issue