Skip to content

Instantly share code, notes, and snippets.

@horvatha
Created August 19, 2016 16:22
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save horvatha/2e11b48f431c53b101db6cb817b2fc7f to your computer and use it in GitHub Desktop.
Save horvatha/2e11b48f431c53b101db6cb817b2fc7f to your computer and use it in GitHub Desktop.
from django.test import TestCase
import re
class MyTestCase(TestCase):
@staticmethod
def remove_csfr(html_code):
csrf_regex = r'<input[^>]+csrfmiddlewaretoken[^>]+>'
return re.sub(csrf_regex, '', html_code)
def assertEqualExceptCSFR(self, html_code1, html_code2):
return self.assertEqual(
self.remove_csfr(html_code1),
self.remove_csfr(html_code2)
)
@mingrammer
Copy link

There is a typo error.

Fix the "remove_csfr" with "remove_csrf"!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment