[Checkins] SVN: grokcore.site/trunk/ Update functional tests to only use zope.app.appsetup instead of zope.app.testing

Sylvain Viollon sylvain at infrae.com
Wed Apr 14 08:26:52 EDT 2010


Log message for revision 110859:
  Update functional tests to only use zope.app.appsetup instead of zope.app.testing
  
  

Changed:
  U   grokcore.site/trunk/CHANGES.txt
  U   grokcore.site/trunk/setup.py
  U   grokcore.site/trunk/src/grokcore/site/ftests/test_grok_functional.py

-=-
Modified: grokcore.site/trunk/CHANGES.txt
===================================================================
--- grokcore.site/trunk/CHANGES.txt	2010-04-14 12:24:08 UTC (rev 110858)
+++ grokcore.site/trunk/CHANGES.txt	2010-04-14 12:26:52 UTC (rev 110859)
@@ -4,9 +4,9 @@
 1.3 (unreleased)
 ----------------
 
-- Nothing changed yet.
+- Update functional tests to only use zope.app.appsetup instead
+  of zope.app.testing.
 
-
 1.2 (2009-12-20)
 ----------------
 

Modified: grokcore.site/trunk/setup.py
===================================================================
--- grokcore.site/trunk/setup.py	2010-04-14 12:24:08 UTC (rev 110858)
+++ grokcore.site/trunk/setup.py	2010-04-14 12:26:52 UTC (rev 110859)
@@ -11,7 +11,7 @@
     )
 
 tests_require = [
-    'zope.app.testing',
+    'zope.app.appsetup',
     'zope.app.zcmlfiles',
     'zope.component',
     'zope.configuration',

Modified: grokcore.site/trunk/src/grokcore/site/ftests/test_grok_functional.py
===================================================================
--- grokcore.site/trunk/src/grokcore/site/ftests/test_grok_functional.py	2010-04-14 12:24:08 UTC (rev 110858)
+++ grokcore.site/trunk/src/grokcore/site/ftests/test_grok_functional.py	2010-04-14 12:26:52 UTC (rev 110859)
@@ -1,48 +1,13 @@
-import re
 import unittest
-import os.path
-
 import grokcore.site
 
 from pkg_resources import resource_listdir
 from zope.testing import doctest, renormalizing
-from zope.app.testing.functional import (HTTPCaller, getRootFolder,
-                                         FunctionalTestSetup, sync, ZCMLLayer)
+from zope.app.appsetup.testlayer import ZODBLayer
 
-ftesting_zcml = os.path.join(os.path.dirname(grokcore.site.__file__), 'ftesting.zcml')
-GrokFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'GrokFunctionalLayer',
-                                allow_teardown=True)
+FunctionalLayer = ZODBLayer(grokcore.site)
 
-def setUp(test):
-    FunctionalTestSetup().setUp()
 
-def tearDown(test):
-    FunctionalTestSetup().tearDown()
-
-checker = renormalizing.RENormalizing([
-    # Accommodate to exception wrapping in newer versions of mechanize
-    (re.compile(r'httperror_seek_wrapper:', re.M), 'HTTPError:'),
-    ])
-
-def http_call(method, path, data=None, **kw):
-    """Function to help make RESTful calls.
-
-    method - HTTP method to use
-    path - testbrowser style path
-    data - (body) data to submit
-    kw - any request parameters
-    """
-    
-    if path.startswith('http://localhost'):
-        path = path[len('http://localhost'):]
-    request_string = '%s %s HTTP/1.1\n' % (method, path)
-    for key, value in kw.items():
-        request_string += '%s: %s\n' % (key, value)
-    if data is not None:
-        request_string += '\r\n'
-        request_string += data
-    return HTTPCaller()(request_string, handle_errors=False)
-
 def suiteFromPackage(name):
     files = resource_listdir(__name__, name)
     suite = unittest.TestSuite()
@@ -54,17 +19,13 @@
 
         dottedname = 'grokcore.site.ftests.%s.%s' % (name, filename[:-3])
         test = doctest.DocTestSuite(
-            dottedname, setUp=setUp, tearDown=tearDown,
-            checker=checker,
-            extraglobs=dict(http=HTTPCaller(),
-                            http_call=http_call,
-                            getRootFolder=getRootFolder,
-                            sync=sync),
+            dottedname,
+            extraglobs=dict(getRootFolder=FunctionalLayer.getRootFolder),
             optionflags=(doctest.ELLIPSIS+
                          doctest.NORMALIZE_WHITESPACE+
                          doctest.REPORT_NDIFF)
             )
-        test.layer = GrokFunctionalLayer
+        test.layer = FunctionalLayer
 
         suite.addTest(test)
     return suite



More information about the checkins mailing list