[Checkins] SVN: grok/trunk/ Add a test for grok_component() used in
a doctest. This needs Martian 0.9.2.
Martijn Faassen
faassen at infrae.com
Tue Nov 20 07:23:30 EST 2007
Log message for revision 81944:
Add a test for grok_component() used in a doctest. This needs Martian 0.9.2.
Changed:
U grok/trunk/src/grok/ftests/test_grok_functional.py
A grok/trunk/src/grok/ftests/testing/
A grok/trunk/src/grok/ftests/testing/__init__.py
A grok/trunk/src/grok/ftests/testing/grok_component.py
U grok/trunk/versions.cfg
-=-
Modified: grok/trunk/src/grok/ftests/test_grok_functional.py
===================================================================
--- grok/trunk/src/grok/ftests/test_grok_functional.py 2007-11-20 12:22:12 UTC (rev 81943)
+++ grok/trunk/src/grok/ftests/test_grok_functional.py 2007-11-20 12:23:29 UTC (rev 81944)
@@ -70,7 +70,8 @@
def test_suite():
suite = unittest.TestSuite()
for name in ['view', 'staticdir', 'xmlrpc', 'traversal', 'form', 'url',
- 'security', 'utility', 'catalog', 'admin', 'site', 'rest']:
+ 'security', 'utility', 'catalog', 'admin', 'site', 'rest',
+ 'testing']:
suite.addTest(suiteFromPackage(name))
return suite
Added: grok/trunk/src/grok/ftests/testing/__init__.py
===================================================================
--- grok/trunk/src/grok/ftests/testing/__init__.py (rev 0)
+++ grok/trunk/src/grok/ftests/testing/__init__.py 2007-11-20 12:23:29 UTC (rev 81944)
@@ -0,0 +1 @@
+#
Added: grok/trunk/src/grok/ftests/testing/grok_component.py
===================================================================
--- grok/trunk/src/grok/ftests/testing/grok_component.py (rev 0)
+++ grok/trunk/src/grok/ftests/testing/grok_component.py 2007-11-20 12:23:29 UTC (rev 81944)
@@ -0,0 +1,38 @@
+"""
+Test grok_component().
+
+grok.testing.grok_component() can be used to grok individual
+components within a doctest, such as adapters. It sets up just enough
+context for some grokking to work, though more complicated grokkers
+which need module context (such as view grokkers) might not work.
+
+This defines the object we want to provide an adapter for::
+
+ >>> class Bar(object):
+ ... pass
+
+This is the interface that we want to adapt to::
+
+ >>> from zope.interface import Interface
+ >>> class IFoo(Interface):
+ ... pass
+
+This is the adapter itself::
+
+ >>> import grok
+ >>> class MyAdapter(grok.Adapter):
+ ... grok.provides(IFoo)
+ ... grok.context(Bar)
+
+Now we will register the adapter using grok_component()::
+
+ >>> from grok.testing import grok_component
+ >>> grok_component('MyAdapter', MyAdapter)
+ True
+
+The adapter should now be available::
+
+ >>> adapted = IFoo(Bar())
+ >>> isinstance(adapted, MyAdapter)
+ True
+"""
Modified: grok/trunk/versions.cfg
===================================================================
--- grok/trunk/versions.cfg 2007-11-20 12:22:12 UTC (rev 81943)
+++ grok/trunk/versions.cfg 2007-11-20 12:23:29 UTC (rev 81944)
@@ -1,7 +1,7 @@
[versions]
ClientForm = 0.2.7
docutils = 0.4
-martian = 0.9.1
+martian = 0.9.2
mechanize = 0.1.7b
Pygments = 0.8.1
pytz = 2007g
More information about the Checkins
mailing list