diff --git a/ckan/lib/base.py b/ckan/lib/base.py index 902112d0b78..4eb576e9e0c 100644 --- a/ckan/lib/base.py +++ b/ckan/lib/base.py @@ -75,8 +75,9 @@ def render_snippet(template_name, **kw): cache_force = kw.pop('cache_force', None) output = render(template_name, extra_vars=kw, cache_force=cache_force, renderer='snippet') - output = '\n\n%s\n\n' % ( - template_name, output, template_name) + if config.get('debug'): + output = ('\n\n%s\n\n' + % (template_name, output, template_name)) return literal(output) diff --git a/ckan/tests/controllers/test_admin.py b/ckan/tests/controllers/test_admin.py index 3685e748aa6..afbbeb4cd57 100644 --- a/ckan/tests/controllers/test_admin.py +++ b/ckan/tests/controllers/test_admin.py @@ -223,6 +223,7 @@ def test_custom_css(self): style_tag = reset_intro_response_html.select('head style') assert_equal(len(style_tag), 0) + @helpers.change_config('debug', True) def test_homepage_style(self): '''Select a homepage style''' app = self._get_test_app() @@ -255,6 +256,7 @@ def test_homepage_style(self): class TestTrashView(helpers.FunctionalTestBase): '''View tests for permanently deleting datasets with Admin Trash.''' + @helpers.change_config('debug', True) def test_trash_view_anon_user(self): '''An anon user shouldn't be able to access trash view.''' app = self._get_test_app() diff --git a/ckan/tests/lib/test_base.py b/ckan/tests/lib/test_base.py index 25b30e14ff0..af9d445882f 100644 --- a/ckan/tests/lib/test_base.py +++ b/ckan/tests/lib/test_base.py @@ -3,6 +3,21 @@ import ckan.tests.helpers as helpers +class TestRenderSnippet(helpers.FunctionalTestBase): + """ + Test ``ckan.lib.base.render_snippet``. + """ + @helpers.change_config('debug', True) + def test_comment_present_if_debug_true(self): + response = self._get_test_app().get('/') + assert '