Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Use HTML parser to compare html snippets

  • Loading branch information...
commit 585aa11d233b7e3e40fe45fa69ef045d8f282345 1 parent 8d35fd4
Ian Clelland authored September 28, 2012 spookylukey committed December 24, 2012
53  tests/regressiontests/admin_inlines/tests.py
@@ -131,19 +131,17 @@ def test_non_related_name_inline(self):
131 131
         response = self.client.get('/admin/admin_inlines/capofamiglia/add/')
132 132
 
133 133
         self.assertContains(response,
134  
-                '<input type="hidden" name="-1-0-id" id="id_-1-0-id" />')
  134
+                '<input type="hidden" name="-1-0-id" id="id_-1-0-id" />', html=True)
135 135
         self.assertContains(response,
136  
-                '<input type="hidden" name="-1-0-capo_famiglia" '
137  
-                'id="id_-1-0-capo_famiglia" />')
  136
+                '<input type="hidden" name="-1-0-capo_famiglia" id="id_-1-0-capo_famiglia" />', html=True)
138 137
         self.assertContains(response,
139 138
                 '<input id="id_-1-0-name" type="text" class="vTextField" '
140 139
                 'name="-1-0-name" maxlength="100" />', html=True)
141 140
 
142 141
         self.assertContains(response,
143  
-                '<input type="hidden" name="-2-0-id" id="id_-2-0-id" />')
  142
+                '<input type="hidden" name="-2-0-id" id="id_-2-0-id" />', html=True)
144 143
         self.assertContains(response,
145  
-                '<input type="hidden" name="-2-0-capo_famiglia" '
146  
-                'id="id_-2-0-capo_famiglia" />')
  144
+                '<input type="hidden" name="-2-0-capo_famiglia" id="id_-2-0-capo_famiglia" />', html=True)
147 145
         self.assertContains(response,
148 146
                 '<input id="id_-2-0-name" type="text" class="vTextField" '
149 147
                 'name="-2-0-name" maxlength="100" />', html=True)
@@ -326,7 +324,8 @@ def test_inline_add_fk_add_perm(self):
326 324
         # Add permission on inner2s, so we get the inline
327 325
         self.assertContains(response, '<h2>Inner2s</h2>')
328 326
         self.assertContains(response, 'Add another Inner2')
329  
-        self.assertContains(response, 'value="3" id="id_inner2_set-TOTAL_FORMS"')
  327
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
  328
+                            'value="3" name="inner2_set-TOTAL_FORMS" />', html=True)
330 329
 
331 330
     def test_inline_change_m2m_add_perm(self):
332 331
         permission = Permission.objects.get(codename='add_book', content_type=self.book_ct)
@@ -345,8 +344,10 @@ def test_inline_change_m2m_change_perm(self):
345 344
         # We have change perm on books, so we can add/change/delete inlines
346 345
         self.assertContains(response, '<h2>Author-book relationships</h2>')
347 346
         self.assertContains(response, 'Add another Author-Book Relationship')
348  
-        self.assertContains(response, 'value="4" id="id_Author_books-TOTAL_FORMS"')
349  
-        self.assertContains(response, '<input type="hidden" name="Author_books-0-id" value="%i"' % self.author_book_auto_m2m_intermediate_id)
  347
+        self.assertContains(response, '<input type="hidden" id="id_Author_books-TOTAL_FORMS" '
  348
+                            'value="4" name="Author_books-TOTAL_FORMS" />', html=True)
  349
+        self.assertContains(response, '<input type="hidden" id="id_Author_books-0-id" '
  350
+                            'value="%i" name="Author_books-0-id" />' % self.author_book_auto_m2m_intermediate_id, html=True)
350 351
         self.assertContains(response, 'id="id_Author_books-0-DELETE"')
351 352
 
352 353
     def test_inline_change_fk_add_perm(self):
@@ -357,8 +358,10 @@ def test_inline_change_fk_add_perm(self):
357 358
         self.assertContains(response, '<h2>Inner2s</h2>')
358 359
         self.assertContains(response, 'Add another Inner2')
359 360
         # 3 extra forms only, not the existing instance form
360  
-        self.assertContains(response, 'value="3" id="id_inner2_set-TOTAL_FORMS"')
361  
-        self.assertNotContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
  361
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
  362
+                                'value="3" name="inner2_set-TOTAL_FORMS" />', html=True)
  363
+        self.assertNotContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
  364
+                            'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
362 365
 
363 366
     def test_inline_change_fk_change_perm(self):
364 367
         permission = Permission.objects.get(codename='change_inner2', content_type=self.inner_ct)
@@ -367,10 +370,13 @@ def test_inline_change_fk_change_perm(self):
367 370
         # Change permission on inner2s, so we can change existing but not add new
368 371
         self.assertContains(response, '<h2>Inner2s</h2>')
369 372
         # Just the one form for existing instances
370  
-        self.assertContains(response, 'value="1" id="id_inner2_set-TOTAL_FORMS"')
371  
-        self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
  373
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
  374
+                                'value="1" name="inner2_set-TOTAL_FORMS" />', html=True)
  375
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
  376
+                            'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
372 377
         # max-num 0 means we can't add new ones
373  
-        self.assertContains(response, 'value="0" id="id_inner2_set-MAX_NUM_FORMS"')
  378
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-MAX_NUM_FORMS" '
  379
+                                'value="0" name="inner2_set-MAX_NUM_FORMS" />', html=True)
374 380
 
375 381
     def test_inline_change_fk_add_change_perm(self):
376 382
         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):
381 387
         # Add/change perm, so we can add new and change existing
382 388
         self.assertContains(response, '<h2>Inner2s</h2>')
383 389
         # One form for existing instance and three extra for new
384  
-        self.assertContains(response, 'value="4" id="id_inner2_set-TOTAL_FORMS"')
385  
-        self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
386  
-
  390
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
  391
+                                'value="4" name="inner2_set-TOTAL_FORMS" />', html=True)
  392
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
  393
+                            'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
387 394
 
388 395
     def test_inline_change_fk_change_del_perm(self):
389 396
         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):
394 401
         # Change/delete perm on inner2s, so we can change/delete existing
395 402
         self.assertContains(response, '<h2>Inner2s</h2>')
396 403
         # One form for existing instance only, no new
397  
-        self.assertContains(response, 'value="1" id="id_inner2_set-TOTAL_FORMS"')
398  
-        self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
  404
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
  405
+                                'value="1" name="inner2_set-TOTAL_FORMS" />', html=True)
  406
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
  407
+                            'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
399 408
         self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
400 409
 
401 410
 
@@ -410,8 +419,10 @@ def test_inline_change_fk_all_perms(self):
410 419
         # All perms on inner2s, so we can add/change/delete
411 420
         self.assertContains(response, '<h2>Inner2s</h2>')
412 421
         # One form for existing instance only, three for new
413  
-        self.assertContains(response, 'value="4" id="id_inner2_set-TOTAL_FORMS"')
414  
-        self.assertContains(response, '<input type="hidden" name="inner2_set-0-id" value="%i"' % self.inner2_id)
  422
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-TOTAL_FORMS" '
  423
+                                'value="4" name="inner2_set-TOTAL_FORMS" />', html=True)
  424
+        self.assertContains(response, '<input type="hidden" id="id_inner2_set-0-id" '
  425
+                            'value="%i" name="inner2_set-0-id" />' % self.inner2_id, html=True)
415 426
         self.assertContains(response, 'id="id_inner2_set-0-DELETE"')
416 427
 
417 428
 

0 notes on commit 585aa11

Please sign in to comment.
Something went wrong with that request. Please try again.