From b2419f98144b4552466000593e601216e7d4a4d4 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Wed, 15 Oct 2014 00:26:39 +0200 Subject: [PATCH] tests: Add test case for a symlink pointing at itself --- tests/data/symlink-loop | 1 + tests/utils/test_path.py | 6 ++++++ 2 files changed, 7 insertions(+) create mode 120000 tests/data/symlink-loop diff --git a/tests/data/symlink-loop b/tests/data/symlink-loop new file mode 120000 index 00000000..c83815d9 --- /dev/null +++ b/tests/data/symlink-loop @@ -0,0 +1 @@ +symlink-loop \ No newline at end of file diff --git a/tests/utils/test_path.py b/tests/utils/test_path.py index 1fdf0b27..ca913f86 100644 --- a/tests/utils/test_path.py +++ b/tests/utils/test_path.py @@ -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):