Extract test utility functions.
This commit is contained in:
parent
b563c50da2
commit
8a6cb39b9f
2 changed files with 20 additions and 18 deletions
|
@ -1,26 +1,10 @@
|
||||||
from nose.tools import eq_ as eq, assert_raises
|
from nose.tools import eq_ as eq, assert_raises
|
||||||
|
|
||||||
import os, errno
|
import os
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
|
||||||
from gitosis import ssh
|
from gitosis import ssh
|
||||||
|
from gitosis.test.util import mkdir, maketemp
|
||||||
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
|
|
||||||
|
|
||||||
def writeFile(path, content):
|
def writeFile(path, content):
|
||||||
tmp = '%s.tmp' % path
|
tmp = '%s.tmp' % path
|
||||||
|
|
18
gitosis/test/util.py
Normal file
18
gitosis/test/util.py
Normal 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
|
Loading…
Reference in a new issue