Skip to content

Instantly share code, notes, and snippets.

@prestontimmons
Created September 28, 2012 16:19
Show Gist options
  • Save prestontimmons/3800756 to your computer and use it in GitHub Desktop.
Save prestontimmons/3800756 to your computer and use it in GitHub Desktop.
Django test with test template loader
from django.template import Template
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import (
setup_test_template_loader,
restore_template_loaders,
override_settings,
)
class TemplateTest(TestCase):
def setUp(self):
templates = {
"template.html": Template("content here"),
}
setup_test_template_loader(templates)
def tearDown(self):
restore_template_loaders()
@override_settings(LOGIN_URL="/login/")
def test_view(self):
request = RequestFactory().get("/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment