# HG changeset patch # User Victor Ng # Date 1219941751 14400 # Node ID a82369f2574eef3a5958c0faa52e01b963210b79 # Parent dfba3a3a434347d44d8ac0a774769547770560de http client tests diff -r dfba3a3a4343 -r a82369f2574e examples/project/settings.py --- a/examples/project/settings.py Thu Aug 28 12:04:55 2008 -0400 +++ b/examples/project/settings.py Thu Aug 28 12:42:31 2008 -0400 @@ -1,4 +1,4 @@ -# Django settings for p1 project. +# Django settings for 'project' project. DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -64,7 +64,7 @@ 'django.middleware.doc.XViewMiddleware', ) -ROOT_URLCONF = 'p1.urls' +ROOT_URLCONF = 'project.urls' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". diff -r dfba3a3a4343 -r a82369f2574e examples/project/tests/test_views.py --- a/examples/project/tests/test_views.py Thu Aug 28 12:04:55 2008 -0400 +++ b/examples/project/tests/test_views.py Thu Aug 28 12:42:31 2008 -0400 @@ -1,6 +1,7 @@ -from django.http import HttpRequest -from project.zoo import views +from django.test.client import Client def test_view_index(): - r = views.index(HttpRequest()) - assert r + c = Client() + resp = c.get('/zoo/') + assert "Just a title" in resp.content + assert "foobar" in resp.content diff -r dfba3a3a4343 -r a82369f2574e examples/project/urls.py --- a/examples/project/urls.py Thu Aug 28 12:04:55 2008 -0400 +++ b/examples/project/urls.py Thu Aug 28 12:42:31 2008 -0400 @@ -6,7 +6,7 @@ urlpatterns = patterns('', # Example: - # (r'^p1/', include('p1.foo.urls')), + (r'^zoo/', include('project.zoo.urls')), # Uncomment the next line to enable admin documentation: # (r'^admin/doc/', include('django.contrib.admindocs.urls')), diff -r dfba3a3a4343 -r a82369f2574e examples/project/zoo/templates/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/templates/index.html Thu Aug 28 12:42:31 2008 -0400 @@ -0,0 +1,8 @@ + + + Just a title + + + {{content}} + + diff -r dfba3a3a4343 -r a82369f2574e examples/project/zoo/tests.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/tests.py Thu Aug 28 12:42:31 2008 -0400 @@ -0,0 +1,14 @@ +from django.test import TestCase +from project.zoo.models import Zoo + +class TestDjango(TestCase): + def testcase1(self): + zoo = Zoo.objects.create(name='blah') + assert Zoo.objects.count() == 1 + import pdb + pdb.set_trace() + + def testcase2(self): + zoo = Zoo.objects.create(name='blah') + assert Zoo.objects.count() == 1 + diff -r dfba3a3a4343 -r a82369f2574e examples/project/zoo/urls.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/project/zoo/urls.py Thu Aug 28 12:42:31 2008 -0400 @@ -0,0 +1,10 @@ +from django.conf.urls.defaults import * + +# Uncomment the next two lines to enable the admin: +# from django.contrib import admin +# admin.autodiscover() + +urlpatterns = patterns('project.zoo.views', + # Example: + (r'^$', 'index'), +) diff -r dfba3a3a4343 -r a82369f2574e examples/project/zoo/views.py --- a/examples/project/zoo/views.py Thu Aug 28 12:04:55 2008 -0400 +++ b/examples/project/zoo/views.py Thu Aug 28 12:42:31 2008 -0400 @@ -1,4 +1,6 @@ # Create your views here. +from django.shortcuts import render_to_response + def index(request): - return 1 + return render_to_response('index.html', {'content': 'foobar'}) diff -r dfba3a3a4343 -r a82369f2574e nosedjango/nosedjango.py --- a/nosedjango/nosedjango.py Thu Aug 28 12:04:55 2008 -0400 +++ b/nosedjango/nosedjango.py Thu Aug 28 12:42:31 2008 -0400 @@ -113,6 +113,7 @@ # no state information passed between individual tests. from django.core.management import call_command + from django.core.urlresolvers import clear_url_caches call_command('flush', verbosity=0, interactive=False) if isinstance(test, nose.case.Test) and \