diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2012-07-07 15:49:00 +0200 |
|---|---|---|
| committer | Florian Apolloner <florian@apolloner.eu> | 2012-07-07 15:49:00 +0200 |
| commit | a4bb7dd552cf9e45cdd0b38938b18c576419fd8d (patch) | |
| tree | 4efc2b8368cb9b8eb446924f482072ead44c5c9b /tests | |
| parent | 52a9e15794ac050afb17837a34407722e7249854 (diff) | |
| parent | 0a68a2994be17ed2669accead331881cb0be41dd (diff) | |
Merge branch 'master' of github.com:django/django
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/staticfiles_tests/tests.py | 12 | ||||
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py index 8321fc2365..7678d7f100 100644 --- a/tests/regressiontests/staticfiles_tests/tests.py +++ b/tests/regressiontests/staticfiles_tests/tests.py @@ -87,14 +87,16 @@ class BaseStaticFilesTestCase(object): template = loader.get_template_from_string(template) return template.render(Context(kwargs)).strip() - def static_template_snippet(self, path): + def static_template_snippet(self, path, asvar=False): + if asvar: + return "{%% load static from staticfiles %%}{%% static '%s' as var %%}{{ var }}" % path return "{%% load static from staticfiles %%}{%% static '%s' %%}" % path - def assertStaticRenders(self, path, result, **kwargs): - template = self.static_template_snippet(path) + def assertStaticRenders(self, path, result, asvar=False, **kwargs): + template = self.static_template_snippet(path, asvar) self.assertEqual(self.render_template(template, **kwargs), result) - def assertStaticRaises(self, exc, path, result, **kwargs): + def assertStaticRaises(self, exc, path, result, asvar=False, **kwargs): self.assertRaises(exc, self.assertStaticRenders, path, result, **kwargs) @@ -368,6 +370,8 @@ class TestCollectionCachedStorage(BaseCollectionTestCase, "/static/does/not/exist.png") self.assertStaticRenders("test/file.txt", "/static/test/file.dad0999e4f8f.txt") + self.assertStaticRenders("test/file.txt", + "/static/test/file.dad0999e4f8f.txt", asvar=True) self.assertStaticRenders("cached/styles.css", "/static/cached/styles.93b1147e8552.css") self.assertStaticRenders("path/", diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 35d01221ab..4aa71f9709 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -1616,6 +1616,8 @@ class Templates(unittest.TestCase): 'static-prefixtag04': ('{% load static %}{% get_media_prefix as media_prefix %}{{ media_prefix }}', {}, settings.MEDIA_URL), 'static-statictag01': ('{% load static %}{% static "admin/base.css" %}', {}, urljoin(settings.STATIC_URL, 'admin/base.css')), 'static-statictag02': ('{% load static %}{% static base_css %}', {'base_css': 'admin/base.css'}, urljoin(settings.STATIC_URL, 'admin/base.css')), + 'static-statictag03': ('{% load static %}{% static "admin/base.css" as foo %}{{ foo }}', {}, urljoin(settings.STATIC_URL, 'admin/base.css')), + 'static-statictag04': ('{% load static %}{% static base_css as foo %}{{ foo }}', {'base_css': 'admin/base.css'}, urljoin(settings.STATIC_URL, 'admin/base.css')), # Verbatim template tag outputs contents without rendering. 'verbatim-tag01': ('{% verbatim %}{{bare }}{% endverbatim %}', {}, '{{bare }}'), |
