[Checkins] SVN: grok/trunk/src/grok/tests/scan/directive test
ZCML-behaviour in case of GrokErrors
Wolfgang Schnerring
wosc at wosc.de
Tue Oct 17 07:18:08 EDT 2006
Log message for revision 70740:
test ZCML-behaviour in case of GrokErrors
Changed:
A grok/trunk/src/grok/tests/scan/directiveerror.py
A grok/trunk/src/grok/tests/scan/directiveimporterror.py
A grok/trunk/src/grok/tests/scan/directiveimporterror_fixture.py
-=-
Added: grok/trunk/src/grok/tests/scan/directiveerror.py
===================================================================
--- grok/trunk/src/grok/tests/scan/directiveerror.py 2006-10-17 11:11:16 UTC (rev 70739)
+++ grok/trunk/src/grok/tests/scan/directiveerror.py 2006-10-17 11:18:08 UTC (rev 70740)
@@ -0,0 +1,25 @@
+"""
+When a GrokImportError occurs, ZCML will give the proper stack trace:
+
+ >>> import grok
+ >>> from zope.configuration import xmlconfig
+ >>> context = xmlconfig.file('meta.zcml', grok)
+
+ >>> ignored = xmlconfig.string('''
+ ... <configure
+ ... xmlns="http://namespaces.zope.org/zope"
+ ... xmlns:grok="http://namespaces.zope.org/grok"
+ ... >
+ ... <grok:grok package="grok.tests.scan.directiveerror"/>
+ ... </configure>''', context=context)
+ Traceback (most recent call last):
+ ...
+ ZopeXMLConfigurationError: File "...", line ...
+ GrokError: No module-level context for
+ <class 'grok.tests.scan.directiveerror.CavePainting'>, please use grok.context.
+
+"""
+import grok
+
+class CavePainting(grok.View):
+ pass
Added: grok/trunk/src/grok/tests/scan/directiveimporterror.py
===================================================================
--- grok/trunk/src/grok/tests/scan/directiveimporterror.py 2006-10-17 11:11:16 UTC (rev 70739)
+++ grok/trunk/src/grok/tests/scan/directiveimporterror.py 2006-10-17 11:18:08 UTC (rev 70740)
@@ -0,0 +1,19 @@
+"""
+When a GrokImportError occurs, ZCML will give the proper stack trace:
+
+ >>> import grok
+ >>> from zope.configuration import xmlconfig
+ >>> context = xmlconfig.file('meta.zcml', grok)
+
+ >>> ignored = xmlconfig.string('''
+ ... <configure
+ ... xmlns="http://namespaces.zope.org/zope"
+ ... xmlns:grok="http://namespaces.zope.org/grok"
+ ... >
+ ... <grok:grok package="grok.tests.scan.directiveimporterror_fixture"/>
+ ... </configure>''', context=context)
+ Traceback (most recent call last):
+ ...
+ ZopeXMLConfigurationError: File "...", line ...
+ GrokImportError: grok.template can only be used on class level.
+"""
Added: grok/trunk/src/grok/tests/scan/directiveimporterror_fixture.py
===================================================================
--- grok/trunk/src/grok/tests/scan/directiveimporterror_fixture.py 2006-10-17 11:11:16 UTC (rev 70739)
+++ grok/trunk/src/grok/tests/scan/directiveimporterror_fixture.py 2006-10-17 11:18:08 UTC (rev 70740)
@@ -0,0 +1,5 @@
+"""
+This will raise a GrokImportError
+"""
+import grok
+grok.template('invalid')
More information about the Checkins
mailing list