Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use HTML parser to compare html snippets

  • Loading branch information...
commit 585aa11d233b7e3e40fe45fa69ef045d8f282345 1 parent 8d35fd4
Ian Clelland clelland authored spookylukey committed
Showing with 32 additions and 21 deletions.
  1. +32 −21 tests/regressiontests/admin_inlines/tests.py
53 tests/regressiontests/admin_inlines/tests.py
View
@@ -131,19 +131,17 @@ def test_non_related_name_inline(self):
response = self.client.get('/admin/admin_inlines/capofamiglia/add/')
self.assertContains(response,
- '<input type="hidden" name="-1-0-id" id="id_-1-0-id" />')
+ '<input type="hidden" name="-1-0-id" id="id_-1-0-id" />', html=True)
self.assertContains(response,
- '<input type="hidden" name="-1-0-capo_famiglia" '
- 'id="id_-1-0-capo_famiglia" />')
+ '<input type="hidden" name="-1-0-capo_famiglia" id="id_-1-0-capo_famiglia" />', html=True)
self.assertContains(response,
'<input id="id_-1-0-name" type="text" class="vTextField" '
'name="-1-0-name" maxlength="100" />', html=True)
self.assertContains(response,
- '<input type="hidden" name="-2-0-id" id="id_-2-0-id" />')
+ '<input type="hidden" name="-2-0-id" id="id_-2-0-id" />', html=True)
self.assertContains(response,
- '<input type="hidden" name="-2-0-capo_famiglia" '
- 'id="id_-2-0-capo_famiglia" />')
+ '<input type="hidden" name="-2-0-capo_famiglia" id="id_-2-0-capo_famiglia" />', html=True)
self.assertContains(response,
'<input id="id_-2-0-name" type="text" class="vTextField" '
'name="-2-0-name" maxlength="100" />', html=True)
@@ -326,7 +324,8 @@ def test_inline_add_fk_add_perm(self):
# Add permission on inner2s, so we get the inline
self.assertContains(response, '<h2>Inner2s</h2>')
self.assertContains(response, 'Add another Inner2')
- self.assertContains(response, 'value="3" id="id_inner2_set-TOTAL_FORMS"')
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
+ 'value="3" name="inner2_set-TOTAL_FORMS" />', html=True)
def test_inline_change_m2m_add_perm(self):
permission = Permission.objects.get(codename='add_book', content_type=self.book_ct)
@@ -345,8 +344,10 @@ def test_inline_change_m2m_change_perm(self):
# We have change perm on books, so we can add/change/delete inlines
self.assertContains(response, '<h2>Author-book relationships</h2>')
self.assertContains(response, 'Add another Author-Book Relationship')
- self.assertContains(response, 'value="4" id="id_Author_books-TOTAL_FORMS"')
- self.assertContains(response, '<input type="hidden" name="Author_books-0-id" value="%i"' % self.author_book_auto_m2m_intermediate_id)
+ self.assertContains(response, '<input type="hidden" id="id_Author_books-TOTAL_FORMS" '
+ 'value="4" name="Author_books-TOTAL_FORMS" />', html=True)
+ self.assertContains(response, '<input type="hidden" id="id_Author_books-0-id" '
+ 'value="%i" name="Author_books-0-id" />' % self.author_book_auto_m2m_intermediate_id, html=True)
self.assertContains(response, 'id="id_Author_books-0-DELETE"')
def test_inline_change_fk_add_perm(self):
@@ -357,8 +358,10 @@ def test_inline_change_fk_add_perm(self):
self.assertContains(response, '<h2>Inner2s</h2>')
self.assertContains(response, 'Add another Inner2')
# 3 extra forms only, not the existing instance form
- self.assertContains(response, 'value="3" id="id_inner2_set-TOTAL_FORMS"')
- self.assertNotContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
+ 'value="3" name="inner2_set-TOTAL_FORMS" />', html=True)
+ self.assertNotContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
+ 'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
def test_inline_change_fk_change_perm(self):
permission = Permission.objects.get(codename='change_inner2', content_type=self.inner_ct)
@@ -367,10 +370,13 @@ def test_inline_change_fk_change_perm(self):
# Change permission on inner2s, so we can change existing but not add new
self.assertContains(response, '<h2>Inner2s</h2>')
# Just the one form for existing instances
- self.assertContains(response, 'value="1" id="id_inner2_set-TOTAL_FORMS"')
- self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
+ 'value="1" name="inner2_set-TOTAL_FORMS" />', html=True)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
+ 'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
# max-num 0 means we can't add new ones
- self.assertContains(response, 'value="0" id="id_inner2_set-MAX_NUM_FORMS"')
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-MAX_NUM_FORMS" '
+ 'value="0" name="inner2_set-MAX_NUM_FORMS" />', html=True)
def test_inline_change_fk_add_change_perm(self):
permission = Permission.objects.get(codename='add_inner2', content_type=self.inner_ct)
@@ -381,9 +387,10 @@ def test_inline_change_fk_add_change_perm(self):
# Add/change perm, so we can add new and change existing
self.assertContains(response, '<h2>Inner2s</h2>')
# One form for existing instance and three extra for new
- self.assertContains(response, 'value="4" id="id_inner2_set-TOTAL_FORMS"')
- self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
-
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
+ 'value="4" name="inner2_set-TOTAL_FORMS" />', html=True)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
+ 'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
def test_inline_change_fk_change_del_perm(self):
permission = Permission.objects.get(codename='change_inner2', content_type=self.inner_ct)
@@ -394,8 +401,10 @@ def test_inline_change_fk_change_del_perm(self):
# Change/delete perm on inner2s, so we can change/delete existing
self.assertContains(response, '<h2>Inner2s</h2>')
# One form for existing instance only, no new
- self.assertContains(response, 'value="1" id="id_inner2_set-TOTAL_FORMS"')
- self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
+ 'value="1" name="inner2_set-TOTAL_FORMS" />', html=True)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
+ 'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
@@ -410,8 +419,10 @@ def test_inline_change_fk_all_perms(self):
# All perms on inner2s, so we can add/change/delete
self.assertContains(response, '<h2>Inner2s</h2>')
# One form for existing instance only, three for new
- self.assertContains(response, 'value="4" id="id_inner2_set-TOTAL_FORMS"')
- self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
+ 'value="4" name="inner2_set-TOTAL_FORMS" />', html=True)
+ self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
+ 'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
Please sign in to comment.
Something went wrong with that request. Please try again.