Hi
I got the same issue.
from django.test import TestCase
class AccountViewTest(TestCase):
def test_account_register(self):
user_data_dict={
'username':'userwerthrthh',
'email':'[EMAIL PROTECTED]',
'password':'psdfsdppps',
'password2':'psdfsdppps',
'user_group_id':2,
'name':'Test User',
'nip':4918851570,
'regon':970931428,
'description':'rtrt rty y',
'city':'sdfg dfggh',
'street':'fdsf dsfg sdfg',
'postcode':111,
}
self.client.post('/account/register/', user_data_dict)
----------------------------------------------------------------------
account/tests.py", line 37, in test_account_register
self.client.post('/account/register/', user_data_dict)
File "/usr/lib/python2.5/site-packages/django/test/client.py", line
243, in post
return self.request(**r)
File "/usr/lib/python2.5/site-packages/django/test/client.py", line
171, in request
response = self.handler(environ)
File "/usr/lib/python2.5/site-packages/django/test/client.py", line
40, in __call__
response = self.get_response(request)
File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 126, in get_response
subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR')
in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path)
TypeError: 'in <string>' requires string as left operand
----------------------------------------------------------------------
If I change a key called 'street' to 'whotever' or replace @ in email
value it works.
any ideas why?
cheers,
Paul
On 15 Lip, 02:28, bshaurette <[EMAIL PROTECTED]> wrote:
> Writing tests for models has been a snap, but I'm having a lot harder
> time with the views.
>
> I'm trying to use the test client, something like this:
>
> from django.test import Client, TestCase
>
> class ViewTest(TestCase):
> def setUp(self):
> self.client = Client()
>
> def test_view_profile(self):
> response = self.client.get('/accounts/profile/', {'username':
> 'newuser1'})
>
> # Check some response details
> self.assertEqual(response.status_code, 200)
> self.assertContains(response, 'Profile View')
>
> But I'm getting errors related to the project settings, most
> specifically this one:
>
> File "/Users/bshaurette/Code/django_trunk/django/core/handlers/
> base.py", line 126, in get_response
> subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR')
> in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path)
> TypeError: 'in <string>' requires string as left operand
>
> I tried setting an INTERNAL_IPS value to get around that, but there
> are other settings errors that pop up. Ultimately, it looks like the
> test is having trouble reconciling paths between the project urls.py
> and the app urls.py ... ?
>
> DoesNotExist: Site matching query does not exist.
>
> I'm not new to writing tests, just to unit testing in Django/Python -
> what would *really* help is if I could see some other examples of view
> testing. I feel like I've been banging my head against a wall for a
> few days now. Has anyone got any recommendations?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---