Skip to content

Commit

Permalink
fix browser default tests: disable CSRF transform rather than try to …
Browse files Browse the repository at this point in the history
…normalize output
  • Loading branch information
davisagli committed Mar 22, 2014
1 parent 1a04f1d commit 3a564ea
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Products/CMFPlone/tests/testBrowserDefault.py
Expand Up @@ -15,12 +15,11 @@
import re
import transaction
import unittest2 as unittest
from lxml.html import fromstring, tostring

RE_REMOVE_DOCCONT = re.compile('\s*href="http://.*?#content"')
RE_REMOVE_SKIPNAV = re.compile('\s*href="http://.*?#portal-globalnav"')
RE_REMOVE_TABS = re.compile('<ul id="portal-globalnav".*?</ul>', re.S)
RE_REMOVE_AUTH = re.compile('_authenticator=[\d\w]+', re.S)
RE_REMOVE_AUTH = re.compile('\_authenticator\=.*?\"', re.S)


class TestPloneToolBrowserDefault(unittest.TestCase):
Expand All @@ -41,6 +40,10 @@ def setUp(self):
'plone.app.theming.interfaces.IThemeSettings.enabled'
] = False

# disable auto-CSRF
from plone.protect import auto
auto.CSRF_DISABLED = True

_createObjectByType('Folder', self.portal, 'folder')
_createObjectByType('Document', self.portal, 'document')
_createObjectByType('File', self.portal, 'file')
Expand All @@ -56,6 +59,10 @@ def setUp(self):
)
)

def tearDown(self):
from plone.protect import auto
auto.CSRF_DISABLED = False

def compareLayoutVsView(self, obj, path="", viewaction=None):
if viewaction is None:
if hasattr(aq_base(obj), 'getLayout'):
Expand Down Expand Up @@ -85,14 +92,9 @@ def compareLayoutVsView(self, obj, path="", viewaction=None):
if not body:
self.fail('No body in response')

# normalize html
body = tostring(fromstring(body))
resolved = tostring(fromstring(resolved))
if not body == resolved:
diff = difflib.unified_diff(
[l.strip() for l in body.split("\n")],
[l.strip() for l in resolved.split("\n")]
)
diff = difflib.unified_diff(body.split("\n"),
resolved.split("\n"))
self.fail("\n".join([line for line in diff]))

def compareLayoutVsCall(self, obj):
Expand Down

0 comments on commit 3a564ea

Please sign in to comment.