Ticket #14774: 14774.tests.diff

File 14774.tests.diff, 1.9 KB (added by Jonas Obrist, 14 years ago)

tests for 14774 (they're failing at the moment)

  • tests/regressiontests/test_utils/tests_25.py

    diff --git a/tests/regressiontests/test_utils/tests_25.py b/tests/regressiontests/test_utils/tests_25.py
    index 4adea6c..05ed317 100644
    a b class AssertNumQueriesTests(TestCase):  
    2626        with self.assertRaises(TypeError):
    2727            with self.assertNumQueries(4000):
    2828                raise TypeError
     29   
     30    def test_with_client(self):
     31        person = Person.objects.create(name='test')
     32       
     33        with self.assertNumQueries(1):
     34            self.client.get('/test_utils/get_person/%s/' % person.pk)
     35           
     36        with self.assertNumQueries(1):
     37            self.client.get('/test_utils/get_person/%s/' % person.pk)
  • new file tests/regressiontests/test_utils/urls.py

    diff --git a/tests/regressiontests/test_utils/urls.py b/tests/regressiontests/test_utils/urls.py
    new file mode 100644
    index 0000000..1109b82
    - +  
     1from django.conf.urls.defaults import *
     2import views
     3
     4urlpatterns = patterns('',
     5    (r'^get_person/(\d+)/$', views.get_person),
     6)
     7 No newline at end of file
  • new file tests/regressiontests/test_utils/views.py

    diff --git a/tests/regressiontests/test_utils/views.py b/tests/regressiontests/test_utils/views.py
    new file mode 100644
    index 0000000..62af0d9
    - +  
     1from django.http import HttpResponse
     2from django.shortcuts import get_object_or_404
     3from models import Person
     4
     5def get_person(request, pk):
     6    person = get_object_or_404(Person, pk=pk)
     7    return HttpResponse(person.name)
     8 No newline at end of file
  • tests/urls.py

    diff --git a/tests/urls.py b/tests/urls.py
    index 01d6408..5fd4e7d 100644
    a b urlpatterns = patterns('',  
    4141
    4242    # special headers views
    4343    (r'special_headers/', include('regressiontests.special_headers.urls')),
     44   
     45    # test util views
     46    (r'test_utils/', include('regressiontests.test_utils.urls')),
    4447)
Back to Top