tests: Add test for current find symlink handling

This commit is contained in:
Thomas Adamcik 2014-10-14 23:51:57 +02:00
parent a8017dfef1
commit de5fe5ebab
4 changed files with 10 additions and 2 deletions

View File

@ -140,7 +140,7 @@ def _find_worker(relative, hidden, done, work, results, errors):
elif stat.S_ISREG(st.st_mode):
results[path] = st
else:
errors[path] = 'Not a file or directory'
errors[path] = Exception('Not a file or directory')
except os.error as e:
errors[path] = e
finally:

1
tests/data/find2/bar Symbolic link
View File

@ -0,0 +1 @@
foo

0
tests/data/find2/foo Normal file
View File

View File

@ -216,11 +216,13 @@ class FindMTimesTest(unittest.TestCase):
DOES_NOT_EXIST = tests.path_to_data_dir('does-no-exist')
SINGLE_FILE = tests.path_to_data_dir('blank.mp3')
SINGLE_SYMLINK = tests.path_to_data_dir('find2/bar')
DATA_DIR = tests.path_to_data_dir('')
FIND_DIR = tests.path_to_data_dir('find')
FIND2_DIR = tests.path_to_data_dir('find2')
def test_basic_dir(self):
result, errors = path.find_mtimes(self.DATA_DIR)
result, errors = path.find_mtimes(self.FIND_DIR)
self.assert_(result)
self.assertEqual(errors, {})
@ -247,6 +249,11 @@ class FindMTimesTest(unittest.TestCase):
for name in path.find_mtimes(self.DATA_DIR)[0]:
self.assertEqual(name, tests.IsA(bytes))
def test_symlinks_are_ignored(self):
result, errors = path.find_mtimes(self.SINGLE_SYMLINK)
self.assertEqual({}, result)
self.assertEqual({self.SINGLE_SYMLINK: tests.IsA(Exception)}, errors)
# TODO: kill this in favour of just os.path.getmtime + mocks
class MtimeTest(unittest.TestCase):