mirror of https://github.com/tLDP/python-tldp
ensure that statfiles includes directories
statfiles was not including directories; it does now
This commit is contained in:
parent
a9203de709
commit
1578e282cc
|
@ -67,6 +67,13 @@ class Test_which(unittest.TestCase):
|
|||
|
||||
class Test_statfiles(unittest.TestCase):
|
||||
|
||||
def test_statfiles_dir_in_result(self):
|
||||
'''Assumes that directory ./testdata/ exists here'''
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
statinfo = statfiles(here, relative=here)
|
||||
self.assertIsInstance(statinfo, dict)
|
||||
self.assertTrue(os.path.basename('testdata') in statinfo)
|
||||
|
||||
def test_statfiles_dir_rel(self):
|
||||
here = os.path.dirname(os.path.abspath(__file__))
|
||||
statinfo = statfiles(here, relative=here)
|
||||
|
|
|
@ -194,7 +194,10 @@ def statfiles(name, relative=None):
|
|||
del statinfo[relpath]
|
||||
else:
|
||||
for root, dirs, files in os.walk(name):
|
||||
for x in files:
|
||||
inodes = list()
|
||||
inodes.extend(dirs)
|
||||
inodes.extend(files)
|
||||
for x in inodes:
|
||||
foundpath = os.path.join(root, x)
|
||||
if relative:
|
||||
relpath = os.path.relpath(foundpath, start=relative)
|
||||
|
|
Loading…
Reference in New Issue