Completed test coverage of views.static.directory_name().

This commit is contained in:
Hasan Ramezani 2018-10-24 02:44:27 +02:00 committed by Tim Graham
parent 10d82c85aa
commit 6a8b57df6a
3 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1 @@
The directory_name() view ignores files that start with a dot.

View File

View File

@ -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',