Skip to content

Commit

Permalink
Add code comments for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaudcolas committed May 20, 2021
1 parent 815759f commit f443718
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tests/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,22 @@ def test_parent_template_from_variable(self):
],
)


class TestGetTemplateDirs(SimpleTestCase):
def get_relative_template_dirs(self):
"""Make paths relative with a predefined root so we can use them in assertions."""
base = os.path.dirname(settings.BASE_DIR)
dirs = get_template_dirs()
return ['/'.join(str(d).replace(base, 'dpl').split('/')[-4:-1]) for d in dirs]

@override_settings(TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
},
])
def test_get_template_dirs_app_dirs(self):
template_dirs = ['/'.join(d.replace(os.path.dirname(settings.BASE_DIR), 'dpl').split('/')[-4:-1]) for d in get_template_dirs()]
self.assertListEqual(template_dirs, [
self.assertListEqual(self.get_relative_template_dirs(), [
'django/contrib/auth',
'dpl/pattern_library',
'dpl/tests',
Expand All @@ -65,8 +72,7 @@ def test_get_template_dirs_app_dirs(self):
},
])
def test_get_template_dirs_list_dirs(self):
template_dirs = ['/'.join(d.replace(os.path.dirname(settings.BASE_DIR), 'dpl').split('/')[-4:-1]) for d in get_template_dirs()]
self.assertListEqual(template_dirs, [
self.assertListEqual(self.get_relative_template_dirs(), [
'dpl/tests/test_one',
'dpl/tests/test_two',
'django/contrib/auth',
Expand Down

0 comments on commit f443718

Please sign in to comment.