[Checkins] SVN: grok/trunk/src/grok/tests/ - added tests for
priority
Christian Theune
ct at gocept.com
Fri Jan 5 12:11:17 EST 2007
Log message for revision 71721:
- added tests for priority
Changed:
A grok/trunk/src/grok/tests/grokker/
A grok/trunk/src/grok/tests/grokker/__init__.py
A grok/trunk/src/grok/tests/grokker/priority.py
A grok/trunk/src/grok/tests/grokker/priority_fixture.py
U grok/trunk/src/grok/tests/test_grok.py
-=-
Added: grok/trunk/src/grok/tests/grokker/__init__.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/__init__.py 2007-01-05 17:10:13 UTC (rev 71720)
+++ grok/trunk/src/grok/tests/grokker/__init__.py 2007-01-05 17:11:16 UTC (rev 71721)
@@ -0,0 +1 @@
+
Property changes on: grok/trunk/src/grok/tests/grokker/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
Added: grok/trunk/src/grok/tests/grokker/priority.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/priority.py 2007-01-05 17:10:13 UTC (rev 71720)
+++ grok/trunk/src/grok/tests/grokker/priority.py 2007-01-05 17:11:16 UTC (rev 71721)
@@ -0,0 +1,52 @@
+"""
+We define grokkers for the three base classes Alpha, Beta, and Gamma with different
+priorities:
+
+- AlphaGrokker with priority 0 (default)
+- BetaGrokker with priority 1
+- GammaGrokker with priority -1
+
+ >>> grok.grok(__name__)
+
+We grok a module that implements subclasses for Alpha, Beta, and Gamma and our
+grokkers get executed in the order of priority (highest first)::
+
+ >>> grok.grok('grok.tests.grokker.priority_fixture')
+ beta
+ alpha
+ gamma
+
+"""
+import grok
+
+
+class Alpha(object):
+ pass
+
+
+class Beta(object):
+ pass
+
+class Gamma(object):
+ pass
+
+class AlphaGrokker(grok.ClassGrokker):
+ component_class = Alpha
+
+ def register(self, context, name, factory, module_info, templates):
+ print "alpha"
+
+
+class BetaGrokker(grok.ClassGrokker):
+ component_class = Beta
+ priority = 1
+
+ def register(self, context, name, factory, module_info, templates):
+ print "beta"
+
+class GammaGrokker(grok.ClassGrokker):
+ component_class = Gamma
+ priority = -1
+
+ def register(self, context, name, factory, module_info, templates):
+ print "gamma"
Property changes on: grok/trunk/src/grok/tests/grokker/priority.py
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
Added: grok/trunk/src/grok/tests/grokker/priority_fixture.py
===================================================================
--- grok/trunk/src/grok/tests/grokker/priority_fixture.py 2007-01-05 17:10:13 UTC (rev 71720)
+++ grok/trunk/src/grok/tests/grokker/priority_fixture.py 2007-01-05 17:11:16 UTC (rev 71721)
@@ -0,0 +1,10 @@
+import grok.tests.grokker.priority
+
+class AlphaSub(grok.tests.grokker.priority.Alpha):
+ pass
+
+class BetaSub(grok.tests.grokker.priority.Beta):
+ pass
+
+class GammaSub(grok.tests.grokker.priority.Gamma):
+ pass
Property changes on: grok/trunk/src/grok/tests/grokker/priority_fixture.py
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
Modified: grok/trunk/src/grok/tests/test_grok.py
===================================================================
--- grok/trunk/src/grok/tests/test_grok.py 2007-01-05 17:10:13 UTC (rev 71720)
+++ grok/trunk/src/grok/tests/test_grok.py 2007-01-05 17:11:16 UTC (rev 71721)
@@ -34,7 +34,7 @@
suite = unittest.TestSuite()
for name in ['adapter', 'error', 'view', 'security', 'scan', 'event',
'zcml', 'static', 'utility', 'xmlrpc', 'container',
- 'traversal', 'form', 'site']:
+ 'traversal', 'form', 'site', 'grokker']:
suite.addTest(suiteFromPackage(name))
return suite
More information about the Checkins
mailing list