Skip to content

Commit

Permalink
Feature #6342: Fix tests for Django 1.4 version.
Browse files Browse the repository at this point in the history
  • Loading branch information
playpauseandstop committed Feb 9, 2012
1 parent ee8d551 commit cd96df0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions testproject/core/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from decimal import Decimal

from django import VERSION
from django.conf import settings as django_settings
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -142,7 +143,13 @@ def setUp(self):
self.edit_url = reverse('admin:setman_settings_changelist')

def test_admin(self):
relative = lambda url: url.replace(self.admin_url, '')
if VERSION[:2] == (1, 3):
relative = lambda url: url.replace(self.admin_url, '')
add_url = relative(self.add_url)
edit_url = relative(self.edit_url)
else:
add_url = self.add_url
edit_url = self.edit_url

response = self.client.get(self.admin_url)
self.assertNotContains(response, 'Settings Manager')
Expand All @@ -153,16 +160,14 @@ def test_admin(self):

self.assertContains(response, 'Settings Manager')
self.assertContains(
response, '<a href="%s">Settings</a>' % relative(self.edit_url)
response, '<a href="%s">Settings</a>' % edit_url
)
self.assertNotContains(
response, '<a href="%s" class="addlink">Add</a>' % \
relative(self.add_url)
response, '<a href="%s" class="addlink">Add</a>' % add_url
)
self.assertContains(
response,
'<a href="%s" class="changelink">Change</a>' % \
relative(self.edit_url)
'<a href="%s" class="changelink">Change</a>' % edit_url
)

def test_admin_edit(self):
Expand Down

0 comments on commit cd96df0

Please sign in to comment.