pydanny/django-uni-form — Issue #121: test_uni_form_invalid_helper does not kick up a TemplateSyntaxError
Author: calvinchengx
Created: 2011-11-19 03:15:01+00:00
State: open

def test_uni_form_invalid_helper(self):
template = get_template_from_string(u"""
{% load uni_form_tags %}
{% uni_form form form_helper %}
""")
c = Context({'form': TestForm(), 'form_helper': "invalid"})

settings.UNIFORM_FAIL_SILENTLY = False
if settings.TEMPLATE_DEBUG:
self.assertRaises(TemplateSyntaxError, lambda:template.render(c))
else:
self.assertRaises(TypeError, lambda:template.render(c))
del settings.UNIFORM_FAIL_SILENTLY

This unit test should kick up a template syntax error when settings.TEMPLATE_DEBUG is true.

However, I am still seeing TypeError instead of a TemplateSyntaxError.

Reference traceback as follows:

./manage.py test uni_form
Creating test database for alias 'default'...
..........E...........
======================================================================
ERROR: test_uni_form_invalid_helper (uni_form.tests.tests.TestFormHelpers)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/calvin/.virtualenvs/booking/src/django-uni-form/uni_form/tests/tests.py", line 218, in test_uni_form_invalid_helper
print 2, template.render(c)
File "/Users/calvin/.virtualenvs/booking/src/django/django/template/base.py", line 139, in render
return self._render(context)
File "/Users/calvin/.virtualenvs/booking/src/django/django/test/utils.py", line 62, in instrumented_test_render
return self.nodelist.render(context)
File "/Users/calvin/.virtualenvs/booking/src/django/django/template/base.py", line 823, in render
bit = self.render_node(node, context)
File "/Users/calvin/.virtualenvs/booking/src/django/django/template/debug.py", line 73, in render_node
return node.render(context)
File "/Users/calvin/.virtualenvs/booking/src/django-uni-form/uni_form/templatetags/uni_form_tags.py", line 147, in render
c = self.get_render(context)
File "/Users/calvin/.virtualenvs/booking/src/django-uni-form/uni_form/templatetags/uni_form_tags.py", line 83, in get_render
raise TypeError('helper object provided to uni_form tag must be a uni_form.helpers.FormHelper object.')
TypeError: helper object provided to uni_form tag must be a uni_form.helpers.FormHelper object.

----------------------------------------------------------------------
Ran 22 tests in 0.257s

FAILED (errors=1)

Am I missing something here or is this unit test not updated yet?