Created
September 28, 2012 16:19
-
-
Save prestontimmons/3800756 to your computer and use it in GitHub Desktop.
Django test with test template loader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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