I have a function to test my URLs which looks like this:
def test_URLs(self):
routes = [
'about/',
'archive/',
'index/',
'admin/',
''
'doesntExist/'
]
for route in routes:
response = self.client.get(route)
self.assertEqual(response.status_code, 200)
and my URL patterns which looks like this:
urlpatterns = patterns('',
#CMS url
url(r'^admin/', include(admin.site.urls)),
url(r'^$', 'core.views.index'),
url(r'^index/', 'core.views.index'),
url(r'about/', 'core.views.about'),
url(r'^archive/', 'core.views.archive'),
url(r'^talks/(?P<slug>[\w\-]+)/$', 'core.views.getTalk'),
In my test_URLs function, the route 'doesntExist/' doesn't exist, rather aptly. When I run my server and try to access doesntExist/
I get the log message
[04/Oct/2013 09:37:40] "GET /doesntExist/ HTTP/1.1" 404 2629
So doesntExist/
definitely doesn't exist yet when I run the above test I get:
Creating test database for alias 'default'...
..
----------------------------------------------------------------------
Ran 2 tests in 0.017s
OK
Why does my test think it exists?