diff --git a/tests/view_tests/media/subdir/.hidden b/tests/view_tests/media/subdir/.hidden new file mode 100644 index 0000000000..3a1a5eb607 --- /dev/null +++ b/tests/view_tests/media/subdir/.hidden @@ -0,0 +1 @@ +The directory_name() view ignores files that start with a dot. diff --git a/tests/view_tests/media/subdir/visible b/tests/view_tests/media/subdir/visible new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/view_tests/tests/test_static.py b/tests/view_tests/tests/test_static.py index 3154ce1703..f4c58e0611 100644 --- a/tests/view_tests/tests/test_static.py +++ b/tests/view_tests/tests/test_static.py @@ -111,6 +111,14 @@ class StaticTests(SimpleTestCase): def test_index(self): response = self.client.get('/%s/' % self.prefix) self.assertContains(response, 'Index of ./') + # Directories have a trailing slash. + self.assertIn('subdir/', response.context['file_list']) + + def test_index_subdir(self): + response = self.client.get('/%s/subdir/' % self.prefix) + self.assertContains(response, 'Index of subdir/') + # File with a leading dot (e.g. .hidden) aren't displayed. + self.assertEqual(response.context['file_list'], ['visible']) @override_settings(TEMPLATES=[{ 'BACKEND': 'django.template.backends.django.DjangoTemplates',