Extract test utility functions.

This commit is contained in:
Tommi Virtanen 2007-06-05 14:05:54 +03:00
parent b563c50da2
commit 8a6cb39b9f
2 changed files with 20 additions and 18 deletions

View file

@ -1,26 +1,10 @@
from nose.tools import eq_ as eq, assert_raises
import os, errno
import os
from cStringIO import StringIO
from gitosis import ssh
def mkdir(path):
try:
os.mkdir(path)
except OSError, e:
if e.errno == errno.EEXIST:
pass
else:
raise
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)
return tmp
from gitosis.test.util import mkdir, maketemp
def writeFile(path, content):
tmp = '%s.tmp' % path

18
gitosis/test/util.py Normal file
View file

@ -0,0 +1,18 @@
import os, errno
def mkdir(path):
try:
os.mkdir(path)
except OSError, e:
if e.errno == errno.EEXIST:
pass
else:
raise
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)
return tmp