Opened 17 years ago

Closed 13 years ago

#6644 closed Bug (fixed)

FormPreview doesn't pass tests

Reported by: alfred.einstein@… Owned by: simeon
Component: contrib.formtools Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

adding 'django.contrib.formtools' to the installed apps and run:

./manage.py test

got:

..EEE.
======================================================================
ERROR: test_form_get (django.contrib.formtools.tests.PreviewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/tests.py", line 48, in test_form_get
    response = self.client.get('/test1/')
  File "/home/visi/Devel/django/djtrunk/django/test/client.py", line 217, in get
    return self.request(**r)
  File "/home/visi/Devel/django/djtrunk/django/core/handlers/base.py", line 82, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 31, in __call__
    return method(request)
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 54, in preview_get
    context_instance=RequestContext(request))
  File "/home/visi/djtrunk/django/shortcuts/__init__.py", line 18, in render_to_response
  File "/home/visi/djtrunk/django/template/loader.py", line 106, in render_to_string
  File "/home/visi/Devel/django/djtrunk/django/test/utils.py", line 21, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/visi/Devel/django/djtrunk/django/template/__init__.py", line 748, in render
    bits.append(self.render_node(node, context))
  File "/home/visi/Devel/django/djtrunk/django/template/debug.py", line 71, in render_node
    result = node.render(context)
  File "/home/visi/Devel/django/djtrunk/django/template/loader_tags.py", line 71, in render
    compiled_parent = self.get_parent(context)
  File "/home/visi/Devel/django/djtrunk/django/template/loader_tags.py", line 66, in get_parent
    raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent
TemplateSyntaxError: Template u'base.html' cannot be extended, because it doesn't exist

======================================================================
ERROR: test_form_preview (django.contrib.formtools.tests.PreviewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/tests.py", line 64, in test_form_preview
    response = self.client.post('/test1/', test_data)
  File "/home/visi/Devel/django/djtrunk/django/test/client.py", line 236, in post
    return self.request(**r)
  File "/home/visi/Devel/django/djtrunk/django/core/handlers/base.py", line 82, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 31, in __call__
    return method(request)
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 63, in preview_post
    return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
  File "/home/visi/djtrunk/django/shortcuts/__init__.py", line 18, in render_to_response
  File "/home/visi/djtrunk/django/template/loader.py", line 106, in render_to_string
  File "/home/visi/Devel/django/djtrunk/django/test/utils.py", line 21, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/visi/Devel/django/djtrunk/django/template/__init__.py", line 748, in render
    bits.append(self.render_node(node, context))
  File "/home/visi/Devel/django/djtrunk/django/template/debug.py", line 71, in render_node
    result = node.render(context)
  File "/home/visi/Devel/django/djtrunk/django/template/loader_tags.py", line 71, in render
    compiled_parent = self.get_parent(context)
  File "/home/visi/Devel/django/djtrunk/django/template/loader_tags.py", line 66, in get_parent
    raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent
TemplateSyntaxError: Template u'base.html' cannot be extended, because it doesn't exist

======================================================================
ERROR: test_form_submit (django.contrib.formtools.tests.PreviewTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/tests.py", line 82, in test_form_submit
    response = self.client.post('/test1/', test_data)
  File "/home/visi/Devel/django/djtrunk/django/test/client.py", line 236, in post
    return self.request(**r)
  File "/home/visi/Devel/django/djtrunk/django/core/handlers/base.py", line 82, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 31, in __call__
    return method(request)
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 72, in post_post
    return self.failed_hash(request) # Security hash failed.
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 116, in failed_hash
    return self.preview_post(request)
  File "/home/visi/Devel/django/djtrunk/django/contrib/formtools/preview.py", line 63, in preview_post
    return render_to_response(self.preview_template, context, context_instance=RequestContext(request))
  File "/home/visi/djtrunk/django/shortcuts/__init__.py", line 18, in render_to_response
  File "/home/visi/djtrunk/django/template/loader.py", line 106, in render_to_string
  File "/home/visi/Devel/django/djtrunk/django/test/utils.py", line 21, in instrumented_test_render
    return self.nodelist.render(context)
  File "/home/visi/Devel/django/djtrunk/django/template/__init__.py", line 748, in render
    bits.append(self.render_node(node, context))
  File "/home/visi/Devel/django/djtrunk/django/template/debug.py", line 71, in render_node
    result = node.render(context)
  File "/home/visi/Devel/django/djtrunk/django/template/loader_tags.py", line 71, in render
    compiled_parent = self.get_parent(context)
  File "/home/visi/Devel/django/djtrunk/django/template/loader_tags.py", line 66, in get_parent
    raise TemplateSyntaxError, "Template %r cannot be extended, because it doesn't exist" % parent
TemplateSyntaxError: Template u'base.html' cannot be extended, because it doesn't exist

----------------------------------------------------------------------
Ran 6 tests in 0.623s

FAILED (errors=3)

Attachments (2)

formtools.diff (1.5 KB ) - added by simeon 16 years ago.
Add tests/base.html to templates dir and hacks TEMPLATE_DIRS in testrunner to load
ticket-6644-r8233.diff (1.3 KB ) - added by mcroydon 16 years ago.
Updated patch to apply against r8233.

Download all attachments as: .zip

Change History (13)

comment:1 by Pete Crosier, 17 years ago

Resolution: invalid
Status: newclosed

Make sure TEMPLATE_DIRS is setup correctly, I can recreate the output above by purposely breaking my TEMPLATE_DIRS setting.

comment:2 by James Zhu <james@…>, 17 years ago

Needs documentation: set
Needs tests: set
Resolution: invalid
Status: closedreopened

It seems that formtools tests assume there's a "base.html" in the TEMPLATE_DIRS, which contains a template block named "content". So the tests will fail if your project don't meet such requirements.

comment:3 by Simon Greenhill, 16 years ago

Triage Stage: UnreviewedAccepted

Can someone write up a patch?

by simeon, 16 years ago

Attachment: formtools.diff added

Add tests/base.html to templates dir and hacks TEMPLATE_DIRS in testrunner to load

comment:4 by simeon, 16 years ago

Has patch: set
Needs tests: unset
Owner: changed from nobody to simeon
Status: reopenednew

Added patch (as per suggestion by Malcolm during sprint) to hack TEMPLATE_DIRS setting in testrunner only and supply a base.html template for the tests. Still not sure about requiring a base.html with content block, but this patch affects patch only, not the app itself.

comment:5 by simeon, 16 years ago

but this patch affects test only, not the app itself...

comment:6 by mcroydon, 16 years ago

Owner: changed from simeon to mcroydon
Status: newassigned

by mcroydon, 16 years ago

Attachment: ticket-6644-r8233.diff added

Updated patch to apply against r8233.

comment:7 by mcroydon, 16 years ago

Owner: changed from mcroydon to nobody
Status: assignednew

comment:8 by simeon, 16 years ago

Owner: changed from nobody to simeon

comment:9 by Julien Phalip, 14 years ago

Type: Bug

comment:10 by Julien Phalip, 14 years ago

Severity: Normal

comment:11 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [16616]:

Fixed #6644 -- Fixed django.contrib.formtools tests to be better isolated when running outside of the Django test suite. Also moved around the new wizard's templates a bit to better fit the common app layout.

Note: See TracTickets for help on using tickets.
Back to Top