tests: Add test case for a symlink pointing at itself

This commit is contained in:
Thomas Adamcik 2014-10-15 00:26:39 +02:00
parent ebb62885cd
commit b2419f9814
2 changed files with 7 additions and 0 deletions

1
tests/data/symlink-loop Symbolic link
View File

@ -0,0 +1 @@
symlink-loop

View File

@ -222,6 +222,7 @@ class FindMTimesTest(unittest.TestCase):
FIND_DIR = tests.path_to_data_dir('find')
FIND2_DIR = tests.path_to_data_dir('find2')
NO_PERMISSION_DIR = tests.path_to_data_dir('no-permission')
SYMLINK_LOOP = tests.path_to_data_dir('symlink-loop')
def test_basic_dir(self):
result, errors = path.find_mtimes(self.FIND_DIR)
@ -272,6 +273,11 @@ class FindMTimesTest(unittest.TestCase):
self.assertEqual({self.SINGLE_SYMLINK: tests.any_int}, result)
self.assertEqual({}, errors)
def test_direct_symlink_loop(self):
result, errors = path.find_mtimes(self.SYMLINK_LOOP, follow=True)
self.assertEqual({}, result)
self.assertEqual({self.SYMLINK_LOOP: tests.IsA(OSError)}, errors)
# TODO: kill this in favour of just os.path.getmtime + mocks
class MtimeTest(unittest.TestCase):