On 15 Lip, 20:54, bshaurette <[EMAIL PROTECTED]> wrote: > For what it's worth, I finally came up with a simple working test forviews. > Mytestswere written correctly all along, I just had to take > care of those errors related to the project settings. It never > occurred me to just set constants at the top of the test file, but > that's what worked. > > import os > from django.test import Client, TestCase > > os.environ['MEDIA_LOCATION'] = '/Users/bshaurette/myproject/public' > INTERNAL_IPS = ('127.0.0.1',)
Thanks for the info and your help. I also added: self.client.defaults={'REMOTE_ADDR':'localhost'} to my setUp method. I think it would be a good idea if web client could set those vars for us as default on startup. > class ViewTests(TestCase): > def setUp(self): > self.client = Client() > > def test_login(self): > response = self.client.post('/accounts/login/', {'username': > 'bshaurette', 'password': 'bshaurette'}) > self.assertEqual(response.status_code, 200) > > def tearDown(self): > self.client.post('/accounts/logout/') > > (we have a pattern in the base project urls.py that looks for that env > variable 'MEDIA_LOCATION' as the location for site media ... > hence ... ) Many thanks Paul Bielecki --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---