mirror of https://github.com/tLDP/python-tldp
get 100% coverage on the utils.py module
This commit is contained in:
parent
6cdf0b65c1
commit
ddb5424941
|
@ -11,11 +11,10 @@ from tldptesttools import TestToolsFilesystem
|
|||
|
||||
# -- SUT
|
||||
from tldp.utils import makefh, which, execute
|
||||
from tldp.utils import statfiles, stem_and_ext
|
||||
from tldp.utils import statfile, statfiles, stem_and_ext
|
||||
from tldp.utils import arg_isexecutable, isexecutable
|
||||
from tldp.utils import arg_isreadablefile, isreadablefile
|
||||
from tldp.utils import arg_isdirectory
|
||||
from tldp.utils import arg_isloglevel
|
||||
from tldp.utils import arg_isdirectory, arg_isloglevel
|
||||
|
||||
|
||||
class Test_isexecutable_and_friends(unittest.TestCase):
|
||||
|
@ -159,6 +158,17 @@ class Test_statfiles(unittest.TestCase):
|
|||
self.assertEquals(0, len(statinfo))
|
||||
|
||||
|
||||
class Test_statfile(TestToolsFilesystem):
|
||||
|
||||
def test_statfile_bogustype(self):
|
||||
with self.assertRaises(TypeError) as ecm:
|
||||
statfile(0)
|
||||
|
||||
def test_statfile_enoent(self):
|
||||
f = ntf(dir=self.tempdir)
|
||||
st = statfile(f.name + '-ENOENT_TEST')
|
||||
|
||||
|
||||
class Test_stem_and_ext(unittest.TestCase):
|
||||
|
||||
def test_stem_and_ext_final_slash(self):
|
||||
|
|
|
@ -209,14 +209,11 @@ def makefh(thing):
|
|||
def statfile(name):
|
||||
'''return posix.stat_result (or None) for a single file name'''
|
||||
try:
|
||||
st = os.stat(name)
|
||||
st = os.lstat(name)
|
||||
except OSError as e:
|
||||
if e.errno != errno.ENOENT:
|
||||
raise e
|
||||
if os.path.islink(name):
|
||||
st = os.lstat(name)
|
||||
else:
|
||||
st = None
|
||||
st = None
|
||||
return st
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue