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 django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to