[Checkins] SVN: megrok.layout/trunk/src/megrok/layout/ Massive tests cleaning

Souheil CHELFOUH souheil at chelfouh.com
Mon Oct 18 05:59:35 EDT 2010


Log message for revision 117664:
  Massive tests cleaning

Changed:
  D   megrok.layout/trunk/src/megrok/layout/ftests/__init__.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/ftesting.zcml
  D   megrok.layout/trunk/src/megrok/layout/ftests/static/empty.js
  D   megrok.layout/trunk/src/megrok/layout/ftests/templates/master.pt
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_form.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_general.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_layout.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_layoutlayers.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_page.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_specializedlayout.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_static.py
  D   megrok.layout/trunk/src/megrok/layout/ftests/test_utils.py
  U   megrok.layout/trunk/src/megrok/layout/tests/__init__.py
  A   megrok.layout/trunk/src/megrok/layout/tests/errors/
  A   megrok.layout/trunk/src/megrok/layout/tests/errors/__init__.py
  A   megrok.layout/trunk/src/megrok/layout/tests/errors/norenderortemplatelayout.py
  A   megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate.py
  A   megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate_templates/
  A   megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate_templates/mylayout.pt
  A   megrok.layout/trunk/src/megrok/layout/tests/errors/samecontext.py
  A   megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/__init__.py
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/layout.py
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/layoutlayers.py
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/specializedlayout.py
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/static/
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/static/empty.js
  A   megrok.layout/trunk/src/megrok/layout/tests/layout/staticfolder.py
  A   megrok.layout/trunk/src/megrok/layout/tests/models/
  A   megrok.layout/trunk/src/megrok/layout/tests/models/__init__.py
  A   megrok.layout/trunk/src/megrok/layout/tests/models/forms.py
  A   megrok.layout/trunk/src/megrok/layout/tests/models/message.py
  A   megrok.layout/trunk/src/megrok/layout/tests/models/page.py
  A   megrok.layout/trunk/src/megrok/layout/tests/models/templates/
  A   megrok.layout/trunk/src/megrok/layout/tests/models/templates/master.pt
  D   megrok.layout/trunk/src/megrok/layout/tests/test_norenderortemplatelayout.py
  A   megrok.layout/trunk/src/megrok/layout/tests/test_package.py
  A   megrok.layout/trunk/src/megrok/layout/tests/test_readme.py
  D   megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate.py
  D   megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate_templates/mylayout.pt
  D   megrok.layout/trunk/src/megrok/layout/tests/test_samecontext.py

-=-
Deleted: megrok.layout/trunk/src/megrok/layout/ftests/__init__.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/__init__.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/__init__.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,23 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import os.path
-from zope.app.testing.functional import ZCMLLayer
-from zope.configuration.config import ConfigurationMachine
-from grokcore.component import zcml
-
-
-ftesting_zcml = os.path.join(
-    os.path.dirname(__file__), 'ftesting.zcml')
-
-FunctionalLayer = ZCMLLayer(
-    ftesting_zcml, __name__, 'FunctionalLayer', allow_teardown=True)
-
-
-def grok(module_name):
-    config = ConfigurationMachine()
-    zcml.do_grok('grokcore.component.meta', config)
-    zcml.do_grok('grokcore.security.meta', config)
-    zcml.do_grok('grokcore.view.meta', config)
-    zcml.do_grok('grokcore.view.templatereg', config)
-    zcml.do_grok(module_name, config)
-    config.execute_actions()

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/ftesting.zcml
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/ftesting.zcml	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/ftesting.zcml	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,51 +0,0 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope"
-    xmlns:grok="http://namespaces.zope.org/grok">
-
-  <include package="zope.component" file="meta.zcml" />
-  <include package="zope.principalregistry" file="meta.zcml" />
-  <include package="zope.security" file="meta.zcml" />
-  <include package="zope.securitypolicy" file="meta.zcml" />
-  <include package="zope.browserpage" file="meta.zcml" />
-  <include package="zope.app.publication" file="meta.zcml" />
-
-  <include package="zope.annotation" />
-  <include package="zope.password" />
-  <include package="zope.security" />
-  <include package="zope.site" />
-  <include package="zope.traversing" />
-  <include package="zope.traversing.browser" />
-  <include package="zope.principalregistry" />
-  <include package="zope.app.appsetup" />
-  <include package="zope.app.publication" />
-
-  <include package="megrok.layout" />
-  <grok:grok package="megrok.layout.ftests" />
-
-
-  <securityPolicy
-      component="zope.securitypolicy.zopepolicy.ZopeSecurityPolicy"
-      />
-
-  <unauthenticatedPrincipal
-      id="zope.anybody"
-      title="Unauthenticated User"
-      />
-
-  <grant
-      permission="zope.View"
-      principal="zope.anybody"
-      />
-
-  <principal
-      id="zope.mgr"
-      title="Manager"
-      login="mgr"
-      password="mgrpw"
-      />
-
-  <role id="zope.Manager" title="Site Manager" />
-  <grantAll role="zope.Manager" />
-  <grant role="zope.Manager" principal="zope.mgr" />
-
-</configure>

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/templates/master.pt
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/templates/master.pt	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/templates/master.pt	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,7 +0,0 @@
-<html>
- <body>
-   <div class="layout" tal:content="structure view/content">
-     here comes the content
-   </div>
- </body>
-</html>

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_form.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_form.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_form.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,154 +0,0 @@
-"""
-  >>> from megrok.layout import ILayout
-  >>> from zope.component import getMultiAdapter
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> cow = Cow()
-  >>> mylayout = getMultiAdapter((request, cow), ILayout)
-
-  Display form:
-  >>> myview = getMultiAdapter((cow, request), name='myview')
-  >>> print myview()
-  <html>
-   <body>
-     <div class="layout">...
-          <tr class="even">
-            <td class="fieldname">
-              Color
-            </td>
-            <td>
-              globally dark
-            </td>
-          </tr>...
-     </div>
-   </body>
-  </html>
-
-  >>> myview
-  <megrok.layout.ftests.test_form.MyView object at ...>
-  >>> myview.layout
-  <megrok.layout.ftests.test_form.Master object at ...>
-  >>> print myview.content()
-   <table class="listing">
-    <thead>
-      <tr>
-        <th class="label-column">&nbsp;</th>
-        <th>&nbsp;</th>
-      </tr>
-    </thead>
-    <tbody>
-  <BLANKLINE>
-        <tr class="even">
-          <td class="fieldname">
-            Color
-          </td>
-          <td>
-            globally dark
-          </td>
-        </tr>
-  <BLANKLINE>
-    </tbody>
-    <tfoot>
-      <tr class="controls">
-        <td colspan="2" class="align-right">
-        </td>
-      </tr>
-    </tfoot>
-  </table>
-  <BLANKLINE>
-
-  Edit form:
-  >>> myeditview = getMultiAdapter((cow, request), name='myeditview')
-  >>> print myeditview()
-  <html>
-   <body>
-     <div class="layout"><form action="http://127.0.0.1" method="post"
-        class="edit-form" enctype="multipart/form-data">
-  <BLANKLINE>
-  <BLANKLINE>
-  <BLANKLINE>
-  <BLANKLINE>
-  <BLANKLINE>
-    <table class="form-fields">
-      <tbody>
-  <BLANKLINE>
-          <tr>
-            <td class="label">
-  <BLANKLINE>
-              <label for="form.color">
-                <span class="required">*</span><span>Color</span>
-              </label>
-            </td>
-            <td class="field">
-              <div class="widget"><input class="textType" id="form.color" name="form.color" size="20" type="text" value="globally dark"  /></div>
-  <BLANKLINE>
-            </td>
-          </tr>
-  <BLANKLINE>
-      </tbody>
-    </table>
-  <BLANKLINE>
-    <div id="actionsView">
-      <span class="actionButtons">
-        <input type="submit" id="form.actions.apply" name="form.actions.apply" value="Apply" class="button" />
-      </span>
-    </div>
-  </form>
-  </div>
-   </body>
-  </html>
-  <BLANKLINE>
-
-  >>> myeditview
-  <megrok.layout.ftests.test_form.MyEditView object at ...>
-  >>> myeditview.layout
-  <megrok.layout.ftests.test_form.Master object at ...>
-  >>> print myeditview.content()
-  <form action="http://127.0.0.1" method="post"
-        class="edit-form" enctype="multipart/form-data">
-     ...<span>Color</span>...
-     ... value="globally dark" ...
-     ... value="Apply" ...
-  </form>
-
-
-"""
-import grokcore.component as grok
-
-from grokcore.view import templatedir
-from megrok.layout import Layout, DisplayForm, EditForm
-from zope import interface, schema
-
-
-templatedir('templates')
-
-
-class ICowProperties(interface.Interface):
-    color = schema.TextLine(title=u"Color")
-
-
-class Cow(grok.Context):
-    grok.implements(ICowProperties)
-    color = u"globally dark"
-
-
-class Master(Layout):
-    grok.name('master')
-    grok.context(Cow)
-
-
-class MyView(DisplayForm):
-    grok.context(Cow)
-
-
-class MyEditView(EditForm):
-    grok.context(Cow)
-
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
-    suite.layer = FunctionalLayer
-    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_general.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_general.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_general.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,32 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import unittest
-import doctest
-from zope.testing import cleanup, module
-import zope.component.eventtesting
-from megrok.layout.ftests import grok
-from grokcore.component.testing import grok_component
-
-
-def moduleSetUp(test):
-    grok('megrok.layout')
-
-def moduleTearDown(test):
-    module.tearDown(test)
-    cleanup.cleanUp()
-
-def test_suite():
-    optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
-    globs = {'grok_component': grok_component, '__name__': 'megrok.layout'}
-    suite = unittest.TestSuite()
-
-    suite.addTest(
-        doctest.DocFileSuite(
-            '../README.txt',
-            optionflags=optionflags,
-            setUp=moduleSetUp,
-            tearDown=moduleTearDown,
-            globs=globs)
-        )
-
-    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_layout.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_layout.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_layout.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,58 +0,0 @@
-"""
-  >>> from megrok.layout import ILayout
-  >>> from zope.component import getMultiAdapter
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> mammoth = Mammoth()
-  >>> mylayout = getMultiAdapter((request, mammoth), ILayout)
-  >>> ILayout.providedBy(mylayout)
-  True
-
-  >>> mylayout.context
-  <megrok.layout.ftests.test_layout.Mammoth object at ...>
-
-  >>> mylayout.render()
-  '<div> MyLayout </div>'
-
-  >>> elephant = Elephant()
-  >>> mycontextlayout = getMultiAdapter((request, elephant), ILayout)
-  >>> mycontextlayout.render()
-  '<div> MyContextLayout </div>'
-"""
-
-import grokcore.component as grok
-
-from zope import interface
-from megrok.layout import Layout
-
-
-class Mammoth(grok.Context):
-    pass
-
-
-class Elephant(grok.Context):
-    pass
-
-
-class MyLayout(Layout):
-    grok.context(interface.Interface)
-
-    def render(self):
-	return "<div> MyLayout </div>"
-
-
-class MyContextLayout(Layout):
-    grok.context(Elephant)
-
-    def render(self):
-	return "<div> MyContextLayout </div>"
-
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_layoutlayers.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_layoutlayers.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_layoutlayers.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,104 +0,0 @@
-"""
-  >>> from zope.app.testing.functional import getRootFolder
-  >>> getRootFolder()["a"] = A()
-  >>> getRootFolder()["b"] = B()
-  >>> from zope.testbrowser.testing import Browser
-  >>> browser = Browser()
-  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
-  >>> browser.handleErrors = False
-
-  >>> browser.open("http://localhost/++skin++mydefaultskin/a/@@myview")
-  >>> print browser.contents
-  <div> A Layout </div>
-
-  >>> browser.open("http://localhost/++skin++myskin/a/@@myview")
-  >>> print browser.contents
-  <div> A2 Layout </div>
-
-  >>> browser.open("http://localhost/++skin++myskin/b/@@myviewb")
-  >>> print browser.contents
-  <div> B Layout </div>
-"""
-
-import grokcore.component as grok
-from grokcore.view import layer, skin
-
-from zope import interface
-from megrok.layout import Layout, Page
-
-from grokcore.view import IDefaultBrowserLayer
-
-class IMyDefaultLayer(IDefaultBrowserLayer):
-    pass
-
-
-class MyDefaultSkin(IMyDefaultLayer):
-    skin('mydefaultskin')
-
-
-layer(IMyDefaultLayer)
-
-
-
-class MySkinLayer(IDefaultBrowserLayer):
-    pass
-
-
-class MySkin(MySkinLayer):
-    skin('myskin')
-
-
-class A(grok.Context):
-    pass
-
-
-class B(grok.Context):
-    pass
-
-
-class ALayout(Layout):
-    grok.context(A)
-
-    def render(self):
-	return "<div> A Layout </div>"
-
-
-class A2Layout(Layout):
-    grok.context(A)
-    layer(MySkinLayer)
-
-    def render(self):
-	return "<div> A2 Layout </div>"
-
-
-class BLayout(Layout):
-    grok.context(B)
-    layer(MySkinLayer)
-
-    def render(self):
-	return "<div> B Layout </div>"
-
-
-class MyView(Page):
-    grok.context(interface.Interface)
-
-    def render(self):
-        return "MYVIEW"
-
-
-class MyViewB(Page):
-    grok.context(interface.Interface)
-    layer(MySkinLayer)
-
-    def render(self):
-        return "MYVIEW"
-
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_page.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_page.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_page.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,59 +0,0 @@
-"""
-  >>> from megrok.layout import ILayout
-  >>> from zope.component import getMultiAdapter
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> cow = Cow()
-  >>> mylayout = getMultiAdapter((request, cow), ILayout)
-  >>> myview = getMultiAdapter((cow, request), name='myview')
-
-
-  >>> print myview()
-  <html>
-   <body>
-     <div class="layout"><p> My nice Content </p></div>
-   </body>
-  </html>
-
-
-  >>> myview
-  <megrok.layout.ftests.test_page.MyView object at ...>
-  >>> myview.layout
-  <megrok.layout.ftests.test_page.Master object at ...>
-  >>> print myview.content()
-  <p> My nice Content </p>
-
-"""
-import grokcore.component as grok
-from grokcore.view import templatedir
-
-from zope import interface
-from megrok.layout import Layout, Page
-
-templatedir('templates')
-
-
-class Cow(grok.Context):
-    pass
-
-
-class Master(Layout):
-    grok.name('master')
-    grok.context(Cow)
-
-
-class MyView(Page):
-    grok.context(interface.Interface)
-
-    def render(self):
-	return "<p> My nice Content </p>"
-
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_specializedlayout.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_specializedlayout.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_specializedlayout.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,103 +0,0 @@
-"""
-  >>> from zope.app.testing.functional import getRootFolder
-  >>> getRootFolder()["one"] = One()
-  >>> getRootFolder()["two"] = Two()
-  >>> from zope.testbrowser.testing import Browser
-  >>> browser = Browser()
-  >>> browser.addHeader('Authorization', 'Basic mgr:mgrpw')
-  >>> browser.handleErrors = False
-
-  >>> browser.open("http://localhost/++skin++askin/one/@@myview")
-  >>> print browser.contents
-  <div> Layout A for context One </div>
-
-  >>> browser.open("http://localhost/++skin++askin/two/@@myview")
-  >>> print browser.contents
-  <div> Layout A for context Two </div>
-
-  >>> browser.open("http://localhost/++skin++bskin/one/@@myview")
-  >>> print browser.contents
-  <div> Layout B for context One </div>
-
-  >>> browser.open("http://localhost/++skin++bskin/two/@@myview")
-  >>> print browser.contents
-  <div> Layout B for context Two </div>
-"""
-
-import grokcore.view as grok
-from grokcore.view import layer, skin
-
-from zope import interface
-from megrok.layout import Layout, Page
-
-from grokcore.view import IDefaultBrowserLayer
-
-class IALayer(IDefaultBrowserLayer):
-    pass
-
-
-class IBLayer(IALayer):
-    pass
-
-
-class ASkin(IALayer):
-    skin('askin')
-
-
-class BSkin(IBLayer):
-    skin('bskin')
-
-
-class One(grok.Context):
-    pass
-
-
-class Two(One):
-    pass
-
-
-class AOneLayout(Layout):
-    grok.context(One)
-    grok.layer(IALayer)
-
-    def render(self):
-	return "<div> Layout A for context One </div>"
-
-class ATwoLayout(Layout):
-    grok.context(Two)
-    grok.layer(IALayer)
-
-    def render(self):
-	return "<div> Layout A for context Two </div>"
-
-class BOneLayout(Layout):
-    grok.context(One)
-    grok.layer(IBLayer)
-
-    def render(self):
-	return "<div> Layout B for context One </div>"
-
-class BTwoLayout(Layout):
-    grok.context(Two)
-    grok.layer(IBLayer)
-
-    def render(self):
-	return "<div> Layout B for context Two </div>"
-
-
-class MyView(Page):
-    grok.context(interface.Interface)
-    grok.layer(IALayer)
-
-    def render(self):
-        return "MyView on IALayouer"
-
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_static.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_static.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_static.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,34 +0,0 @@
-"""
-  >>> from megrok.layout import ILayout
-  >>> from zope.component import getMultiAdapter
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> mongo = Dummy()
-  >>> mylayout = getMultiAdapter((request, mongo), ILayout)
-  >>> mylayout.static
-  <grokcore.view.components.DirectoryResource object at ...>
-  >>> mylayout.static['empty.js']
-  <zope.browserresource.file.FileResource object at ...>
-"""
-
-import grokcore.component as grok
-from megrok.layout import Layout
-
-
-class Dummy(grok.Context):
-    pass
-
-
-class LayoutWithResources(Layout):
-
-    def render(self):
-        return ""
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite  

Deleted: megrok.layout/trunk/src/megrok/layout/ftests/test_utils.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/ftests/test_utils.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/ftests/test_utils.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,79 +0,0 @@
-"""
-  >>> from megrok.layout import ILayout
-  >>> from zope.component import getMultiAdapter
-  >>> from zope.publisher.browser import TestRequest
-  >>> request = TestRequest()
-  >>> kitty = Cat()
-  >>> mylayout = getMultiAdapter((request, kitty), ILayout)
-  >>> myview = getMultiAdapter((kitty, request), name='utils')
-
-  >>> print myview.application_url()
-  Traceback (most recent call last):
-  ...
-  ComponentLookupError: No site found.
-
-  >>> from zope.site.hooks import setSite
-  >>> root = getRootFolder()
-  >>> setSite(root)
-  >>> print myview.application_url()
-  http://127.0.0.1
-
-  >>> print myview.flash(u'test')
-  None
-
-  >>> from zope.security.management import newInteraction
-  >>> newInteraction(request)
-
-  >>> grok.testing.grok('megrok.layout.messages')
-  >>> print myview.flash(u'test')
-  True
-
-  >>> from zope.component import getUtility
-  >>> from z3c.flashmessage.interfaces import IMessageReceiver
-  >>> receiver = getUtility(IMessageReceiver)
-  >>> messages = [i for i in receiver.receive()]
-  >>> messages
-  [<z3c.flashmessage.message.Message object at ...>]
-
-  >>> print ", ".join([msg.message for msg in messages])
-  test
-  
-  >>> from zope.security.management import endInteraction
-  >>> endInteraction()
-
-"""
-import grokcore.component as grok
-from grokcore.view import templatedir
-
-from zope import interface
-from megrok.layout import Layout, Page
-
-templatedir('templates')
-
-
-class Cat(grok.Context):
-    pass
-
-
-class Master(Layout):
-    grok.name('master')
-    grok.context(Cat)
-
-
-class Utils(Page):
-    grok.context(interface.Interface)
-
-    def render(self):
-	return "<p>A purring cat</p>"
-
-
-def test_suite():
-    from zope.testing import doctest
-    from zope.app.testing import functional
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
-        extraglobs={"getRootFolder": functional.getRootFolder}
-        )
-    suite.layer = FunctionalLayer
-    return suite

Modified: megrok.layout/trunk/src/megrok/layout/tests/__init__.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/__init__.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/tests/__init__.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1 +1,70 @@
-#
+# -*- coding: utf-8 -*-
+
+import zope.component
+from zope.component.interfaces import IComponentLookup
+from zope.component.testlayer import ZCMLFileLayer
+from zope.container import btree
+from zope.container.interfaces import ISimpleReadContainer
+from zope.container.traversal import ContainerTraversable
+from zope.interface import Interface
+from zope.site.folder import rootFolder
+from zope.site.site import LocalSiteManager, SiteManagerAdapter
+from zope.traversing.interfaces import ITraversable
+from zope.traversing.testing import setUp as traversingSetUp
+from zope.configuration.config import ConfigurationMachine
+from grokcore.component import zcml
+
+from zope.component import provideHandler, getGlobalSiteManager
+from zope.session.interfaces import IClientId, IClientIdManager, ISession
+from zope.session.interfaces import ISessionDataContainer
+from zope.session.interfaces import ISessionPkgData, ISessionData
+from zope.session.session import ClientId, Session
+from zope.session.session import PersistentSessionDataContainer
+from zope.session.session import RAMSessionDataContainer
+from zope.session.http import CookieClientIdManager
+from zope.publisher.interfaces import IRequest
+
+
+class MegrokLayoutLayer(ZCMLFileLayer):
+    
+    def setUp(self):
+        ZCMLFileLayer.setUp(self)
+    
+        # Set up site manager adapter
+        zope.component.provideAdapter(
+            SiteManagerAdapter, (Interface,), IComponentLookup)
+    
+        # Set up traversal
+        traversingSetUp()
+        zope.component.provideAdapter(
+            ContainerTraversable, (ISimpleReadContainer,), ITraversable)
+
+        # Session
+        zope.component.provideAdapter(ClientId, (IRequest,), IClientId)
+        zope.component.provideAdapter(Session, (IRequest,), ISession)
+        zope.component.provideUtility(CookieClientIdManager(), IClientIdManager)
+        sdc = PersistentSessionDataContainer()
+        zope.component.provideUtility(sdc, ISessionDataContainer, '')
+    
+        # Set up site
+        site = rootFolder()
+        site.setSiteManager(LocalSiteManager(site))
+        zope.component.hooks.setSite(site)
+        
+        return site
+    
+
+    def tearDown(self):
+        ZCMLFileLayer.tearDown(self)
+        zope.component.hooks.resetHooks()
+        zope.component.hooks.setSite()
+
+
+def grok(module_name):
+    config = ConfigurationMachine()
+    zcml.do_grok('grokcore.component.meta', config)
+    zcml.do_grok('grokcore.security.meta', config)
+    zcml.do_grok('grokcore.view.meta', config)
+    zcml.do_grok('grokcore.view.templatereg', config)
+    zcml.do_grok(module_name, config)
+    config.execute_actions()

Added: megrok.layout/trunk/src/megrok/layout/tests/errors/norenderortemplatelayout.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/errors/norenderortemplatelayout.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/errors/norenderortemplatelayout.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,17 @@
+"""
+  >>> grok.testing.grok(__name__)
+  Traceback (most recent call last):
+  ...
+  ConfigurationExecutionError: <class 'martian.error.GrokError'>: View <class 'megrok.layout.tests.errors.norenderortemplatelayout.MyLayout'> has no associated template or 'render' method.
+  in:
+  <BLANKLINE>
+"""
+
+import grokcore.component as grok
+from grokcore.view import View
+from megrok.layout import Layout
+from zope.interface import Interface
+
+
+class MyLayout(Layout):
+    grok.context(Interface)

Copied: megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,20 @@
+"""
+  >>> grok.testing.grok(__name__)
+  Traceback (most recent call last):
+  ...
+  ConfigurationExecutionError: <class 'martian.error.GrokError'>: Multiple possible ways to render view <class 'megrok.layout.tests.errors.renderandtemplate.MyLayout'>. It has both a 'render' method as well as an associated template.
+  in:
+  <BLANKLINE>
+"""
+
+import grokcore.component as grok
+from grokcore.view import View
+from megrok.layout import Layout
+from zope.interface import Interface
+
+
+class MyLayout(Layout):
+    grok.context(Interface)
+
+    def render(self):
+        return ""

Copied: megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate_templates/mylayout.pt (from rev 117663, megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate_templates/mylayout.pt)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate_templates/mylayout.pt	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/errors/renderandtemplate_templates/mylayout.pt	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1 @@
+<div> </div>

Copied: megrok.layout/trunk/src/megrok/layout/tests/errors/samecontext.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/tests/test_samecontext.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/errors/samecontext.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/errors/samecontext.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,19 @@
+"""
+  >>> grok.testing.grok(__name__) 
+  Traceback (most recent call last):
+  ...
+  ConfigurationConflictError: Conflicting configuration actions
+     For: ('adapter', (<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>, <InterfaceClass zope.interface.Interface>), <InterfaceClass megrok.layout.interfaces.ILayout>)
+"""
+
+import grokcore.component as grok
+from megrok.layout import Layout
+from zope.interface import Interface
+
+
+class MyLayout(Layout):
+    grok.context(Interface)
+
+
+class MyOtherLayout(Layout):
+    grok.context(Interface)

Added: megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/ftesting.zcml	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,18 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:grok="http://namespaces.zope.org/grok">
+
+  <include package="zope.component" file="meta.zcml" />
+  <include package="zope.security" file="meta.zcml" />
+  <include package="megrok.layout" file="meta.zcml" />
+  
+  <include package="zope.annotation" />
+  <include package="zope.security" />
+  <include package="megrok.layout" />  
+
+  <grok:grok package=".layout" />
+  <grok:grok package=".models" />
+
+  <!-- We do not grok the other packages on purpose -->
+
+</configure>

Copied: megrok.layout/trunk/src/megrok/layout/tests/layout/layout.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/ftests/test_layout.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/layout/layout.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/layout/layout.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,47 @@
+"""
+  >>> from megrok.layout import ILayout
+  >>> from zope.component import getMultiAdapter
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> mammoth = Mammoth()
+  >>> mylayout = getMultiAdapter((request, mammoth), ILayout)
+  >>> ILayout.providedBy(mylayout)
+  True
+
+  >>> mylayout.context
+  <megrok.layout.tests.layout.layout.Mammoth object at ...>
+
+  >>> mylayout.render()
+  '<div> MyLayout </div>'
+
+  >>> elephant = Elephant()
+  >>> mycontextlayout = getMultiAdapter((request, elephant), ILayout)
+  >>> mycontextlayout.render()
+  '<div> MyContextLayout </div>'
+"""
+
+import grokcore.component as grok
+from zope import interface
+from megrok.layout import Layout
+
+
+class Mammoth(grok.Context):
+    pass
+
+
+class Elephant(grok.Context):
+    pass
+
+
+class MyLayout(Layout):
+    grok.context(interface.Interface)
+
+    def render(self):
+	return "<div> MyLayout </div>"
+
+
+class MyContextLayout(Layout):
+    grok.context(Elephant)
+
+    def render(self):
+	return "<div> MyContextLayout </div>"

Added: megrok.layout/trunk/src/megrok/layout/tests/layout/layoutlayers.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/layout/layoutlayers.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/layout/layoutlayers.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,84 @@
+"""
+  >>> a = A()
+  >>> b = B()
+
+  >>> from zope.publisher.browser import TestRequest
+  >>> from zope.interface import directlyProvides
+  >>> from zope.component import getMultiAdapter
+
+  >>> request = TestRequest()
+
+  >>> directlyProvides(request, IDefaultLayer)
+  >>> view = getMultiAdapter((a, request), name="myview")
+  >>> print view()
+  A Layout
+
+  >>> directlyProvides(request, IAnotherLayer)
+  >>> view = getMultiAdapter((a, request), name="myview")
+  >>> print view()
+  A2 Layout
+
+  >>> view = getMultiAdapter((b, request), name="myview")
+  >>> print view()
+  B Layout
+"""
+
+import grokcore.view as grok
+from megrok.layout import Layout, Page
+from zope.interface import Interface
+
+
+class IDefaultLayer(grok.IDefaultBrowserLayer):
+    pass
+
+
+class IAnotherLayer(grok.IDefaultBrowserLayer):
+    pass
+
+
+class A(grok.Context):
+    pass
+
+
+class B(grok.Context):
+    pass
+
+
+class ALayout(Layout):
+    grok.context(A)
+    grok.layer(IDefaultLayer)
+
+    def render(self):
+	return "A Layout"
+
+
+class A2Layout(Layout):
+    grok.context(A)
+    grok.layer(IAnotherLayer)
+
+    def render(self):
+	return "A2 Layout"
+
+
+class BLayout(Layout):
+    grok.context(B)
+    grok.layer(IAnotherLayer)
+
+    def render(self):
+	return "B Layout"
+
+
+class MyView(Page):
+    grok.context(Interface)
+    grok.layer(IDefaultLayer)
+
+    def render(self):
+        return "MYVIEW"
+
+
+class MyViewB(Page):
+    grok.context(Interface)
+    grok.layer(IAnotherLayer)
+
+    def render(self):
+        return "MYVIEW"

Added: megrok.layout/trunk/src/megrok/layout/tests/layout/specializedlayout.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/layout/specializedlayout.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/layout/specializedlayout.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,93 @@
+"""
+  >>> one = One()
+  >>> two = Two()
+
+  >>> from zope.publisher.browser import TestRequest
+  >>> from zope.interface import directlyProvides
+  >>> from zope.component import getMultiAdapter
+
+  >>> request = TestRequest()
+
+We test on the first layer layer::
+
+  >>> directlyProvides(request, IALayer)
+  >>> view = getMultiAdapter((one, request), name="myview")
+  >>> print view()
+  Layout A for context One
+
+  >>> view = getMultiAdapter((two, request), name="myview")
+  >>> print view()
+  Layout A for context Two
+
+We switch the layer::
+
+  >>> directlyProvides(request, IBLayer)
+  >>> view = getMultiAdapter((one, request), name="myview")
+  >>> print view()
+  Layout B for context One
+
+  >>> view = getMultiAdapter((two, request), name="myview")
+  >>> print view()
+  Layout B for context Two
+  
+"""
+import grokcore.view as grok
+from zope.interface import Interface
+from megrok.layout import Layout, Page
+from grokcore.view import IDefaultBrowserLayer
+
+
+class IALayer(IDefaultBrowserLayer):
+    pass
+
+
+class IBLayer(IALayer):
+    pass
+
+
+class One(grok.Context):
+    pass
+
+
+class Two(One):
+    pass
+
+
+class AOneLayout(Layout):
+    grok.context(One)
+    grok.layer(IALayer)
+
+    def render(self):
+	return "Layout A for context One"
+
+
+class ATwoLayout(Layout):
+    grok.context(Two)
+    grok.layer(IALayer)
+
+    def render(self):
+	return "Layout A for context Two"
+
+
+class BOneLayout(Layout):
+    grok.context(One)
+    grok.layer(IBLayer)
+
+    def render(self):
+	return "Layout B for context One"
+
+
+class BTwoLayout(Layout):
+    grok.context(Two)
+    grok.layer(IBLayer)
+
+    def render(self):
+	return "Layout B for context Two"
+
+
+class MyView(Page):
+    grok.context(Interface)
+    grok.layer(IALayer)
+
+    def render(self):
+        return "MyView on IALayouer"

Copied: megrok.layout/trunk/src/megrok/layout/tests/layout/staticfolder.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/ftests/test_static.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/layout/staticfolder.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/layout/staticfolder.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,25 @@
+"""
+  >>> from megrok.layout import ILayout
+  >>> from zope.component import getMultiAdapter
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> mongo = Dummy()
+  >>> mylayout = getMultiAdapter((request, mongo), ILayout)
+  >>> mylayout.static
+  <grokcore.view.components.DirectoryResource object at ...>
+  >>> mylayout.static['empty.js']
+  <zope.browserresource.file.FileResource object at ...>
+"""
+
+import grokcore.component as grok
+from megrok.layout import Layout
+
+
+class Dummy(grok.Context):
+    pass
+
+
+class LayoutWithResources(Layout):
+
+    def render(self):
+        return ""

Copied: megrok.layout/trunk/src/megrok/layout/tests/models/forms.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/ftests/test_form.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/models/forms.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/models/forms.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,147 @@
+"""
+  >>> from megrok.layout import ILayout
+  >>> from zope.component import getMultiAdapter
+  >>> from zope.publisher.browser import TestRequest
+
+  >>> cow = Cow()
+  >>> request = TestRequest()
+  
+  >>> mylayout = getMultiAdapter((request, cow), ILayout)
+
+  Display form:
+  >>> myview = getMultiAdapter((cow, request), name='myview')
+  >>> print myview()
+  <html>
+   <body>
+     <div class="layout">...
+          <tr class="even">
+            <td class="fieldname">
+              Color
+            </td>
+            <td>
+              globally dark
+            </td>
+          </tr>...
+     </div>
+   </body>
+  </html>
+
+  >>> myview
+  <megrok.layout.tests.models.forms.MyView object at ...>
+  >>> myview.layout
+  <megrok.layout.tests.models.forms.Master object at ...>
+  >>> print myview.content()
+   <table class="listing">
+    <thead>
+      <tr>
+        <th class="label-column">&nbsp;</th>
+        <th>&nbsp;</th>
+      </tr>
+    </thead>
+    <tbody>
+  <BLANKLINE>
+        <tr class="even">
+          <td class="fieldname">
+            Color
+          </td>
+          <td>
+            globally dark
+          </td>
+        </tr>
+  <BLANKLINE>
+    </tbody>
+    <tfoot>
+      <tr class="controls">
+        <td colspan="2" class="align-right">
+        </td>
+      </tr>
+    </tfoot>
+  </table>
+  <BLANKLINE>
+
+  Edit form:
+  >>> myeditview = getMultiAdapter((cow, request), name='myeditview')
+  >>> print myeditview()
+  <html>
+   <body>
+     <div class="layout"><form action="http://127.0.0.1" method="post"
+        class="edit-form" enctype="multipart/form-data">
+  <BLANKLINE>
+  <BLANKLINE>
+  <BLANKLINE>
+  <BLANKLINE>
+  <BLANKLINE>
+    <table class="form-fields">
+      <tbody>
+  <BLANKLINE>
+          <tr>
+            <td class="label">
+  <BLANKLINE>
+              <label for="form.color">
+                <span class="required">*</span><span>Color</span>
+              </label>
+            </td>
+            <td class="field">
+              <div class="widget"><input class="textType" id="form.color" name="form.color" size="20" type="text" value="globally dark"  /></div>
+  <BLANKLINE>
+            </td>
+          </tr>
+  <BLANKLINE>
+      </tbody>
+    </table>
+  <BLANKLINE>
+    <div id="actionsView">
+      <span class="actionButtons">
+        <input type="submit" id="form.actions.apply" name="form.actions.apply" value="Apply" class="button" />
+      </span>
+    </div>
+  </form>
+  </div>
+   </body>
+  </html>
+  <BLANKLINE>
+
+  >>> myeditview
+  <megrok.layout.tests.models.forms.MyEditView object at ...>
+  >>> myeditview.layout
+  <megrok.layout.tests.models.forms.Master object at ...>
+  >>> print myeditview.content()
+  <form action="http://127.0.0.1" method="post"
+        class="edit-form" enctype="multipart/form-data">
+     ...<span>Color</span>...
+     ... value="globally dark" ...
+     ... value="Apply" ...
+  </form>
+
+
+"""
+import grokcore.component as grok
+
+from grokcore.view import templatedir
+from megrok.layout import Layout, DisplayForm, EditForm
+from zope import interface, schema
+
+
+templatedir('templates')
+
+
+class ICowProperties(interface.Interface):
+    color = schema.TextLine(title=u"Color")
+
+
+class Cow(grok.Context):
+    grok.implements(ICowProperties)
+    color = u"globally dark"
+
+
+class Master(Layout):
+    grok.name('master')
+    grok.context(Cow)
+
+
+class MyView(DisplayForm):
+    grok.context(Cow)
+
+
+class MyEditView(EditForm):
+    grok.context(Cow)

Copied: megrok.layout/trunk/src/megrok/layout/tests/models/message.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/ftests/test_utils.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/models/message.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/models/message.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,57 @@
+"""
+  >>> from megrok.layout import ILayout
+  >>> from zope.component import getMultiAdapter
+  >>> from zope.publisher.browser import TestRequest
+  
+  >>> kitty = Cat()
+  >>> request = TestRequest()
+  >>> mylayout = getMultiAdapter((request, kitty), ILayout)
+  >>> myview = getMultiAdapter((kitty, request), name='utils')
+
+  >>> print myview.flash(u'test')
+  None
+
+  >>> from zope.security.management import newInteraction
+  >>> newInteraction(request)
+
+  >>> grok.testing.grok('megrok.layout.messages')
+  >>> print myview.flash(u'test')
+  True
+
+  >>> from zope.component import getUtility
+  >>> from z3c.flashmessage.interfaces import IMessageReceiver
+  >>> receiver = getUtility(IMessageReceiver)
+  >>> messages = [i for i in receiver.receive()]
+  >>> messages
+  [<z3c.flashmessage.message.Message object at ...>]
+
+  >>> print ", ".join([msg.message for msg in messages])
+  test
+  
+  >>> from zope.security.management import endInteraction
+  >>> endInteraction()
+
+"""
+import grokcore.component as grok
+from grokcore.view import templatedir
+
+from zope import interface
+from megrok.layout import Layout, Page
+
+templatedir('templates')
+
+
+class Cat(grok.Context):
+    pass
+
+
+class Master(Layout):
+    grok.name('master')
+    grok.context(Cat)
+
+
+class Utils(Page):
+    grok.context(interface.Interface)
+
+    def render(self):
+	return "<p>A purring cat</p>"

Copied: megrok.layout/trunk/src/megrok/layout/tests/models/page.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/ftests/test_page.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/models/page.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/models/page.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,48 @@
+"""
+  >>> from megrok.layout import ILayout
+  >>> from zope.component import getMultiAdapter
+  >>> from zope.publisher.browser import TestRequest
+  >>> request = TestRequest()
+  >>> cow = Cow()
+  >>> mylayout = getMultiAdapter((request, cow), ILayout)
+  >>> myview = getMultiAdapter((cow, request), name='myview')
+
+
+  >>> print myview()
+  <html>
+   <body>
+     <div class="layout"><p> My nice Content </p></div>
+   </body>
+  </html>
+
+
+  >>> myview
+  <megrok.layout.tests.models.page.MyView object at ...>
+  >>> myview.layout
+  <megrok.layout.tests.models.page.Master object at ...>
+  >>> print myview.content()
+  <p> My nice Content </p>
+
+"""
+import grokcore.component as grok
+from grokcore.view import templatedir
+from megrok.layout import Layout, Page
+from zope import interface
+
+templatedir('templates')
+
+
+class Cow(grok.Context):
+    pass
+
+
+class Master(Layout):
+    grok.name('master')
+    grok.context(Cow)
+
+
+class MyView(Page):
+    grok.context(interface.Interface)
+
+    def render(self):
+	return "<p> My nice Content </p>"

Copied: megrok.layout/trunk/src/megrok/layout/tests/models/templates/master.pt (from rev 117663, megrok.layout/trunk/src/megrok/layout/ftests/templates/master.pt)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/models/templates/master.pt	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/models/templates/master.pt	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,7 @@
+<html>
+ <body>
+   <div class="layout" tal:content="structure view/content">
+     here comes the content
+   </div>
+ </body>
+</html>

Deleted: megrok.layout/trunk/src/megrok/layout/tests/test_norenderortemplatelayout.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/test_norenderortemplatelayout.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/tests/test_norenderortemplatelayout.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,27 +0,0 @@
-"""
-  >>> grok.testing.grok(__name__)
-  Traceback (most recent call last):
-  ...
-  ConfigurationExecutionError: <class 'martian.error.GrokError'>: View <class 'megrok.layout.tests.test_norenderortemplatelayout.MyLayout'> has no associated template or 'render' method.
-  in:
-  <BLANKLINE>
-"""
-
-import grokcore.component as grok
-from grokcore.view import View
-from megrok.layout import Layout
-from zope.interface import Interface
-
-
-class MyLayout(Layout):
-    grok.context(Interface)
-
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite

Added: megrok.layout/trunk/src/megrok/layout/tests/test_package.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/test_package.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/test_package.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+import unittest
+import pkg_resources
+import megrok.layout.tests
+from zope.testing import doctest
+
+
+def make_test(dottedname):
+    test = doctest.DocTestSuite(
+        dottedname,
+        optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE)
+    test.layer = megrok.layout.tests.MegrokLayoutLayer(megrok.layout.tests)
+    return test
+
+
+def suiteFromPackage(name):
+    files = pkg_resources.resource_listdir(__name__, name)
+    suite = unittest.TestSuite()
+    for filename in files:
+        if not filename.endswith('.py'):
+            continue
+        if filename.endswith('_fixture.py'):
+            continue
+        if filename == '__init__.py':
+            continue
+
+        dottedname = 'megrok.layout.tests.%s.%s' % (name, filename[:-3])
+        suite.addTest(make_test(dottedname))
+    return suite
+
+
+def test_suite():
+    suite = unittest.TestSuite()
+    for name in ['layout', 'models', 'errors']:
+        suite.addTest(suiteFromPackage(name))
+    return suite

Copied: megrok.layout/trunk/src/megrok/layout/tests/test_readme.py (from rev 117663, megrok.layout/trunk/src/megrok/layout/ftests/test_general.py)
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/test_readme.py	                        (rev 0)
+++ megrok.layout/trunk/src/megrok/layout/tests/test_readme.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -0,0 +1,35 @@
+# -*- coding: utf-8 -*-
+
+import doctest
+import unittest
+import megrok.layout.tests
+from zope.testing import cleanup, module
+from grokcore.component.testing import grok_component
+
+
+def moduleSetUp(test):
+    megrok.layout.tests.grok('megrok.layout')
+
+
+def moduleTearDown(test):
+    module.tearDown(test)
+    cleanup.cleanUp()
+
+
+def test_suite():
+    
+    optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
+    globs = {'grok_component': grok_component, '__name__': 'megrok.layout'}
+    suite = unittest.TestSuite()
+
+    suite.addTest(
+        doctest.DocFileSuite(
+            '../README.txt',
+            optionflags=optionflags,
+            setUp=moduleSetUp,
+            tearDown=moduleTearDown,
+            globs=globs),
+        )
+    layer = megrok.layout.tests.MegrokLayoutLayer(megrok.layout.tests)
+
+    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,29 +0,0 @@
-"""
-  >>> grok.testing.grok(__name__)
-  Traceback (most recent call last):
-  ...
-  ConfigurationExecutionError: <class 'martian.error.GrokError'>: Multiple possible ways to render view <class 'megrok.layout.tests.test_renderandtemplate.MyLayout'>. It has both a 'render' method as well as an associated template.
-  in:
-  <BLANKLINE>
-"""
-
-import grokcore.component as grok
-from grokcore.view import View
-from megrok.layout import Layout
-from zope.interface import Interface
-
-
-class MyLayout(Layout):
-    grok.context(Interface)
-
-    def render(self):
-        return ""
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite

Deleted: megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate_templates/mylayout.pt
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate_templates/mylayout.pt	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/tests/test_renderandtemplate_templates/mylayout.pt	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1 +0,0 @@
-<div> </div>

Deleted: megrok.layout/trunk/src/megrok/layout/tests/test_samecontext.py
===================================================================
--- megrok.layout/trunk/src/megrok/layout/tests/test_samecontext.py	2010-10-18 09:59:28 UTC (rev 117663)
+++ megrok.layout/trunk/src/megrok/layout/tests/test_samecontext.py	2010-10-18 09:59:35 UTC (rev 117664)
@@ -1,29 +0,0 @@
-"""
-  >>> grok.testing.grok(__name__) 
-  Traceback (most recent call last):
-  ...
-  ConfigurationConflictError: Conflicting configuration actions
-     For: ('adapter', (<InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>, <InterfaceClass zope.interface.Interface>), <InterfaceClass megrok.layout.interfaces.ILayout>)
-"""
-
-import grokcore.component as grok
-from megrok.layout import Layout
-from zope.interface import Interface
-
-
-class MyLayout(Layout):
-    grok.context(Interface)
-
-
-class MyOtherLayout(Layout):
-    grok.context(Interface)
-
-
-def test_suite():
-    from zope.testing import doctest
-    from megrok.layout.ftests import FunctionalLayer
-    suite = doctest.DocTestSuite(
-        optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS
-        )
-    suite.layer = FunctionalLayer
-    return suite



More information about the checkins mailing list