diff --git a/pelican/tests/test_utils.py b/pelican/tests/test_utils.py index d967b247..2ae8758c 100644 --- a/pelican/tests/test_utils.py +++ b/pelican/tests/test_utils.py @@ -461,6 +461,9 @@ class TestCopy(unittest.TestCase): self.assertTrue(os.path.exists(path), 'Directory does not exist: %s' % path) + def _create_symlink(self, path, *name): + os.symlink(path, os.path.join(self.root_dir, *name)) + def test_copy_file_same_path(self): self._create_file('a.txt') utils.copy(os.path.join(self.root_dir, 'a.txt'), @@ -517,6 +520,20 @@ class TestCopy(unittest.TestCase): self._exist_dir('b0', 'b1', 'b2', 'b3', 'b') self._exist_file('b0', 'b1', 'b2', 'b3', 'b', 'a.txt') + def test_copy_symlink(self): + self._create_dir('f') + self._create_dir('q') + self._create_dir('q', 'r') + self._create_file('q', 'r', 'f.txt') + sympathy = os.path.join(self.root_dir, 'q') + self._create_symlink(sympathy, 'f', 'q') + utils.copy(os.path.join(self.root_dir, 'f'), + os.path.join(self.root_dir, 'm')) + self._exist_dir('m') + self._exist_dir('m', 'q') + self._exist_dir('m', 'q', 'r') + self._exist_file('m', 'q', 'r', 'f.txt') + class TestDateFormatter(unittest.TestCase): '''Tests that the output of DateFormatter jinja filter is same as diff --git a/pelican/utils.py b/pelican/utils.py index d2e896c6..08767017 100644 --- a/pelican/utils.py +++ b/pelican/utils.py @@ -324,7 +324,7 @@ def copy(source, destination, ignores=None): source_, destination_) return - for src_dir, subdirs, others in os.walk(source_): + for src_dir, subdirs, others in os.walk(source_, followlinks=True): dst_dir = os.path.join(destination_, os.path.relpath(src_dir, source_))