From 0922bbf18d3ae8f37e1823df2dbc270d33334548 Mon Sep 17 00:00:00 2001 From: Yusuke Miyazaki Date: Mon, 12 Oct 2015 15:34:16 +0900 Subject: Fixed #25346 -- Allowed collectstatic to delete broken symlinks. --- tests/staticfiles_tests/test_management.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py index 09557185ed..94166f9888 100644 --- a/tests/staticfiles_tests/test_management.py +++ b/tests/staticfiles_tests/test_management.py @@ -323,8 +323,8 @@ class TestCollectionLinks(CollectionTestCase, TestDefaults): the standard file resolving tests here, to make sure using ``--link`` does not change the file-selection semantics. """ - def run_collectstatic(self): - super(TestCollectionLinks, self).run_collectstatic(link=True) + def run_collectstatic(self, clear=False): + super(TestCollectionLinks, self).run_collectstatic(link=True, clear=clear) def test_links_created(self): """ @@ -340,3 +340,13 @@ class TestCollectionLinks(CollectionTestCase, TestDefaults): os.unlink(path) self.run_collectstatic() self.assertTrue(os.path.islink(path)) + + def test_clear_broken_symlink(self): + """ + With ``--clear``, broken symbolic links are deleted. + """ + nonexistent_file_path = os.path.join(settings.STATIC_ROOT, 'nonexistent.txt') + broken_symlink_path = os.path.join(settings.STATIC_ROOT, 'symlink.txt') + os.symlink(nonexistent_file_path, broken_symlink_path) + self.run_collectstatic(clear=True) + self.assertFalse(os.path.lexists(broken_symlink_path)) -- cgit v1.3