Created
November 8, 2011 15:39
-
-
Save flavianmissi/1348085 to your computer and use it in GitHub Desktop.
Testing with Django's RequestFactory
This file contains 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.test.client import RequestFactory | |
from django.utils.unittest import TestCase | |
from myapp.views import my_view | |
class MyViewTestCase(TestCase): | |
def test_my_view_should_return_200_status_code(self): | |
request = RequestFactory().get('url_for_the_view') | |
request.custom_attr = ':)' | |
response = my_view(request) | |
self.assertEqual(200, response.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment