Ticket #15929: tests-2.py

File tests-2.py, 1.0 KB (added by Aymeric Augustin, 14 years ago)
Line 
1# Embed a dummy URLconf to make the test self-contained
2from django.conf.urls.defaults import patterns, include, url
3from django.http import HttpResponse
4urlpatterns = patterns('',
5 url(r'', lambda request: HttpResponse('')),
6)
7
8
9from django.test import TestCase
10from django.test.client import RequestFactory
11
12
13class TestViews(TestCase):
14
15 urls = __name__
16
17 def setUp(self):
18 self.factory = RequestFactory()
19
20 def common_test_that_should_always_pass(self):
21 request = self.factory.get('/')
22 request.session = {}
23 self.assertFalse(hasattr(request, 'user'))
24
25 def test_request(self):
26 self.common_test_that_should_always_pass() # OK
27
28 def test_request_after_client(self):
29 # apart from the next line the three tests are identical
30 self.client.get('/')
31 self.common_test_that_should_always_pass() # FAIL
32
33 def test_request_after_client_2(self):
34 # This test is executed after the previous one thus also fails
35 self.common_test_that_should_always_pass() # FAIL
36
Back to Top