Hi,

I have a unit test that tests that a comment can be posted on an entry
in a Django blog. Posting a comment myself in the browser works fine,
but the test always fails with this error:

"TemplateSyntaxError: Caught VariableDoesNotExist while rendering:
Failed lookup for key [request] in u'[{}]'"

Which suggests the use of the 'request' variable in a template isn't
working. I guess it's a ContextProcessor problem, but I'm stuck as to
why it fails in the test. Here's the test:

----
from django.test.client import Client
from django.test import TestCase
import datetime, time
from weblog.models import Entry
from django.contrib.comments.forms import CommentSecurityForm

class WeblogBaseTestCase(TestCase):
    fixtures = ['../../aggregator/fixtures/test_data.json', ]

class CommentTestCase(WeblogBaseTestCase):

    def post_comment(self, entry_id=1):
        form = CommentSecurityForm( Entry.live.get(pk=entry_id) )
        timestamp = int(time.time())
        security_hash = form.initial_security_hash(timestamp)
        c = Client()
        response = c.post('/cmnt/post/', {
                                'name': 'Bobby',
                                'email': 'bo...@example.com',
                                'url': '',
                                'comment': 'Hello',
                                'content_type': 'weblog.entry',
                                'timestamp': timestamp,
                                'object_pk': entry_id,
                                'security_hash': security_hash,
                            },follow=True)

        self.failUnlessEqual(response.status_code, 200)
----

I'm stumped as to why this error is generated in the test, but not on
the site, and I'm not sure how to poke around to see where it's going
wrong. Any thoughts?

Thanks.

-- 
http://www.gyford.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to