From c5bff951b19285a281479c8316ec0878a7564cce Mon Sep 17 00:00:00 2001 From: Yuri Prezument Date: Tue, 19 Jan 2016 16:41:37 +0200 Subject: [PATCH] Regression test for #718 --- compressor/tests/test_offline.py | 24 +++++++++++++++++++ .../test_extends_recursion/admin/index.html | 1 + .../test_compressor_offline.html | 6 +++++ 3 files changed, 31 insertions(+) create mode 100644 compressor/tests/test_templates/test_extends_recursion/admin/index.html create mode 100644 compressor/tests/test_templates/test_extends_recursion/test_compressor_offline.html diff --git a/compressor/tests/test_offline.py b/compressor/tests/test_offline.py index 6433911..d63b49d 100644 --- a/compressor/tests/test_offline.py +++ b/compressor/tests/test_offline.py @@ -12,6 +12,7 @@ from unittest import SkipTest from django.core.management.base import CommandError from django.template import Template, Context from django.test import TestCase +from django.test.utils import override_settings from django.utils import six from compressor.cache import flush_offline_manifest, get_offline_manifest @@ -629,3 +630,26 @@ class OfflineCompressComplexTestCase(OfflineTestCaseMixin, TestCase): rendered_template = self._render_template(engine) result = (result[0], result[2]) self.assertEqual(rendered_template, ''.join(result) + '\n') + + +class OfflineCompressExtendsRecursionTestCase(OfflineTestCaseMixin, TestCase): + """ + Test that templates extending templates with the same name + (e.g. admin/index.html) don't cause an infinite test_extends_recursion + """ + templates_dir = 'test_extends_recursion' + engines = ('django',) + + INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.staticfiles', + 'compressor', + ] + + @override_settings(INSTALLED_APPS=INSTALLED_APPS) + def _test_offline(self, engine): + count, result = CompressCommand().compress( + log=self.log, verbosity=self.verbosity, engine=engine) + self.assertEqual(count, 1) diff --git a/compressor/tests/test_templates/test_extends_recursion/admin/index.html b/compressor/tests/test_templates/test_extends_recursion/admin/index.html new file mode 100644 index 0000000..e1b6530 --- /dev/null +++ b/compressor/tests/test_templates/test_extends_recursion/admin/index.html @@ -0,0 +1 @@ +{% extends "admin/index.html" %} diff --git a/compressor/tests/test_templates/test_extends_recursion/test_compressor_offline.html b/compressor/tests/test_templates/test_extends_recursion/test_compressor_offline.html new file mode 100644 index 0000000..d505229 --- /dev/null +++ b/compressor/tests/test_templates/test_extends_recursion/test_compressor_offline.html @@ -0,0 +1,6 @@ +{% load compress %} + +{% compress js%} + +{% endcompress %} +{# The real error is caused by "admin/index.html" #}