[Checkins] SVN: zope.app.zptpage/trunk/src/zope/app/zptpage/browser/tests.py Decouple tests from zope.publisher implementation

Dmitry Vasiliev dima at hlabs.spb.ru
Wed May 16 01:17:17 EDT 2007


Log message for revision 75792:
  Decouple tests from zope.publisher implementation

Changed:
  U   zope.app.zptpage/trunk/src/zope/app/zptpage/browser/tests.py

-=-
Modified: zope.app.zptpage/trunk/src/zope/app/zptpage/browser/tests.py
===================================================================
--- zope.app.zptpage/trunk/src/zope/app/zptpage/browser/tests.py	2007-05-16 05:09:40 UTC (rev 75791)
+++ zope.app.zptpage/trunk/src/zope/app/zptpage/browser/tests.py	2007-05-16 05:17:17 UTC (rev 75792)
@@ -15,15 +15,19 @@
 
 $Id$
 """
+
+import re
 import unittest
+from zope.testing import renormalizing
 from zope.app.testing.functional import BrowserTestCase
 from zope.app.zptpage.zptpage import ZPTPage
 from xml.sax.saxutils import escape
 from zope.app.zptpage.testing import ZPTPageLayer
 
+
 class ZPTPageTest(BrowserTestCase):
 
-    content = u'<html><body><h1 tal:content="request/URL/1" /></body></html>' 
+    content = u'<html><body><h1 tal:content="request/URL/1" /></body></html>'
 
     def addZPTPage(self):
         zptpage = ZPTPage()
@@ -32,7 +36,6 @@
         root['zptpage'] = zptpage
         self.commit()
 
-
     def testAddForm(self):
         response = self.publish(
             '/+/zope.app.zptpage.ZPTPage=',
@@ -48,7 +51,6 @@
         self.checkForBrokenLinks(body, '/+/zope.app.zptpage.ZPTPage=',
                                  'mgr:mgrpw')
 
-
     def testAdd(self):
         response = self.publish(
             '/+/zope.app.zptpage.ZPTPage=',
@@ -86,7 +88,6 @@
         self.assertEqual(zptpage.expand, True)
         self.assertEqual(zptpage.evaluateInlineCode, True)
 
-
     def testEditForm(self):
         self.addZPTPage()
         response = self.publish(
@@ -100,7 +101,6 @@
         self.assert_(escape(self.content) in body)
         self.checkForBrokenLinks(body, '/zptpage/@@edit.html', 'mgr:mgrpw')
 
-
     def testEdit(self):
         self.addZPTPage()
         response = self.publish(
@@ -142,9 +142,9 @@
         self.assertEqual(response.getStatus(), 200)
         body = response.getBody()
         # Check for a string from the default template
-        self.assert_(escape(u'Z3 UI') in body) 
+        self.assert_(escape(u'Z3 UI') in body)
         self.failIf(u"Macro expansion failed" in body)
-        
+
     def testIndex(self):
         self.addZPTPage()
         response = self.publish(
@@ -200,10 +200,16 @@
         self.assertEqual(zptpage.evaluateInlineCode, True)
 
 
+checker = renormalizing.RENormalizing([
+    (re.compile(r"HTTP/1\.1 (\d\d\d) .*"), r"HTTP/1.1 \1 <MESSAGE>"),
+    ])
+
+
 def test_suite():
     from zope.app.testing.functional import FunctionalDocFileSuite
-    collector = FunctionalDocFileSuite('collector266.txt', 'collector269.txt')
-    url = FunctionalDocFileSuite('url.txt')
+    collector = FunctionalDocFileSuite(
+        'collector266.txt', 'collector269.txt', checker=checker)
+    url = FunctionalDocFileSuite('url.txt', checker=checker)
     collector.layer = ZPTPageLayer
     ZPTPageTest.layer = ZPTPageLayer
     url.layer = ZPTPageLayer
@@ -213,5 +219,6 @@
         url,
         ))
 
+
 if __name__ == '__main__':
     unittest.main(defaultTest='test_suite')



More information about the Checkins mailing list