On Tue, Nov 25, 2008 at 8:40 PM, Julien Phalip <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I've got a view which uses a different template depending on an input
> parameter. For example:
>
> def my_view(request, theme):
> ...
> return render_to_response('my_app/%s/page.html' %s theme, {...})
>
> I would like to write some tests for this view, but I couldn't find
> any clean way to do so. So far, the only way I've found was to create
> a fake folder in the app's templates:
>
> my_app/
> templates/
> my_app/
> test_blah/
> page.html
> models.py
> tests.py
> views.py
>
> And then I can test the view by sending it the parameter 'test_blah'.
> It works fine, but it means I have to ship my app with that dirty
> "test_blah" folder.
>
> Is there any other way to proceed?
Check out django.contrib.auth.tests.views.py. The ChangePasswordTest
does some fancy footwork during the setUp and tearDown to install some
templates for testing purposes. You still need to ship the templates
as part of your project tarball, but they don't need to be in a
production-visible location - you can hide them away as part of the
testing infrastructure.
Yours,
Russ Magee %-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---