Re: Why does this test fail?

2017-12-04 Thread Johann Spies
My question was answered on Stackoverflow:

The correct line in the function should be

response = client.get('/wos_2017_2/') 


*because of my project urls.py that I did not provide initially:*

urlpatterns = [
 url(r'^wos_2017_2/', include('wos_2017_2.urls')),
 url(r'^admin/', admin.site.urls),
]



 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/16c0194c-b5df-406f-a447-0df904c5ae9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why does this test fail?

2017-12-04 Thread Johann Spies
I am new to Testing Driven Development as well as to Django and will 
appreciate some help please.

I have just worked through the tutorials of the official documentation for 
1.11 and am trying 
to get going with TDD and Django.

The app is wos_2017_2 and I get this in the shell (which is run in the 
project root)

in the app's urls.py I have

>>> from django.test import Client
>>> client = Client()
>>> response = client.get('/')
Not Found: /
>>> response = client.get('/wos_2017_2/')
>>> response
.status_code
200

from . import views

from django.conf.urls import url

urlpatterns = [
 url(r'^$', views.index, name='index'),

]

and the in "wos_2017_2/test.py"


import unittest
from django.test import TestCase
from django.test import Client


# Create your tests here.

from .models import *
from .views import *

class SimpleTest(unittest.TestCase):

def test_index(self):
client = Client()
response = client.get('/')
self.assertEqual(response.status_code, 200)


And the test fails with
FAIL: test_index (wos_2017_2.tests.SimpleTest)
--
Traceback (most recent call last):
  File "/home/js/django/wos/wos_2017_2/tests.py", line 16, in test_index
self.assertEqual(response.status_code, 200)
AssertionError: 404 != 200

--
Ran 1 test in 0.006s

Using the url
http://localhost:8000/wos_2017_2/

in a browser works as expected.

Johann

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5aaaf15d-db66-4fca-b44e-39b8159d38be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial - include question

2009-04-11 Thread Johann Spies

2009/4/11 Alex Gaynor :
> mysite/urls.py needs to have the full urlpatterns = thing like the
> polls/urls.py has so it would look like:
>
> from django.conf.urls.defaults import *
>
> admin.autodiscover()
>
> urlpatterns = patterns('',
>  (r'^polls/', include('mysite.polls.urls')),
> )

Thanks!

Regards
Johann

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Tutorial - include question

2009-04-11 Thread Johann Spies

Working through the tutorial everything went well until I came to the
section "Decoupling the URLconfs" where
the "include" option for urls in a subdirectory is not working as advertised.

What did I do wrong?


In mysite/urls.py I have:

==
from django.conf.urls.defaults import *

(r'^polls/', include('mysite.polls.urls')),

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
=
And in mysite/polls/urls.py  have
=
from django.conf.urls.defaults import *

urlpatterns = patterns('mysite.polls.views',
(r'^$', 'index'),
(r'^(?P\d+)/$', 'detail'),
(r'^(?P\d+)/results/$', 'results'),
(r'^(?P\d+)/vote/$', 'vote'),
)
=
But this results in:

Traceback (most recent call last):

  File "/var/lib/python-support/python2.6/django/core/servers/basehttp.py",
line 278, in run
self.result = application(self.environ, self.start_response)

  File "/var/lib/python-support/python2.6/django/core/servers/basehttp.py",
line 635, in __call__
return self.application(environ, start_response)

  File "/var/lib/python-support/python2.6/django/core/handlers/wsgi.py",
line 239, in __call__
response = self.get_response(request)

  File "/var/lib/python-support/python2.6/django/core/handlers/base.py",
line 67, in get_response
response = middleware_method(request)

  File "/var/lib/python-support/python2.6/django/middleware/common.py",
line 56, in process_request
if (not _is_valid_path(request.path_info) and

  File "/var/lib/python-support/python2.6/django/middleware/common.py",
line 142, in _is_valid_path
urlresolvers.resolve(path)

  File "/var/lib/python-support/python2.6/django/core/urlresolvers.py",
line 246, in resolve
return get_resolver(urlconf).resolve(path)

  File "/var/lib/python-support/python2.6/django/core/urlresolvers.py",
line 179, in resolve
for pattern in self.urlconf_module.urlpatterns:

AttributeError: 'module' object has no attribute 'urlpatterns'


Regards.

Johann

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---