[Checkins] SVN: grokcore.view/trunk/src/grokcore/view/tests/view/shared_template Add a test that shows all UserWarning issued when sharing template directory
Vincent Fretin
vincent.fretin at gmail.com
Fri Jul 3 10:20:36 EDT 2009
Log message for revision 101443:
Add a test that shows all UserWarning issued when sharing template directory
Changed:
A grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir.py
A grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir_fixture.py
A grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/
A grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/cavepainting.pt
A grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/food.pt
A grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/unassociated.pt
-=-
Added: grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir.py (rev 0)
+++ grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir.py 2009-07-03 14:20:35 UTC (rev 101443)
@@ -0,0 +1,33 @@
+"""
+When modules share a template directory, templates that have not been associated with any view class of a given module issue a UserWarning:
+
+ >>> from grokcore.view.testing import warn
+ >>> import warnings
+ >>> saved_warn = warnings.warn
+ >>> warnings.warn = warn
+
+ >>> import shared_template_dir_fixture
+
+ >>> grok.testing.grok(__name__)
+ From grok.testing's warn():
+ ...UserWarning: Found the following unassociated template(s) when grokking
+ 'grokcore.view.tests.view.shared_template_dir': food, unassociated. Define view classes inheriting from
+ grok.View to enable the template(s)...
+
+ >>> grok.testing.grok(shared_template_dir_fixture.__name__)
+ From grok.testing's warn():
+ ...UserWarning: Found the following unassociated template(s) when grokking
+ 'grokcore.view.tests.view.shared_template_dir_fixture': cavepainting, unassociated. Define view classes inheriting from
+ grok.View to enable the template(s)...
+
+"""
+import grokcore.view as grok
+
+
+grok.templatedir("shared_templates")
+
+class Mammoth(grok.Context):
+ pass
+
+class CavePainting(grok.View):
+ pass
Added: grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir_fixture.py
===================================================================
--- grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir_fixture.py (rev 0)
+++ grokcore.view/trunk/src/grokcore/view/tests/view/shared_template_dir_fixture.py 2009-07-03 14:20:35 UTC (rev 101443)
@@ -0,0 +1,11 @@
+"""
+This should issue a UserWarning.
+"""
+import grokcore.view as grok
+from shared_template_dir import Mammoth
+
+grok.templatedir("shared_templates")
+
+class Food(grok.View):
+ grok.context(Mammoth)
+
Added: grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/cavepainting.pt
===================================================================
--- grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/cavepainting.pt (rev 0)
+++ grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/cavepainting.pt 2009-07-03 14:20:35 UTC (rev 101443)
@@ -0,0 +1,5 @@
+<html>
+<body>
+ME GROK PAINT CAVE!
+</body>
+</html>
Added: grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/food.pt
===================================================================
--- grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/food.pt (rev 0)
+++ grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/food.pt 2009-07-03 14:20:35 UTC (rev 101443)
@@ -0,0 +1,5 @@
+<html>
+<body>
+ME GROK EAT MAMMOTH!
+</body>
+</html>
Added: grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/unassociated.pt
===================================================================
--- grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/unassociated.pt (rev 0)
+++ grokcore.view/trunk/src/grokcore/view/tests/view/shared_templates/unassociated.pt 2009-07-03 14:20:35 UTC (rev 101443)
@@ -0,0 +1,3 @@
+This template does not have an associated view class (in other words,
+there's no grokcore.view.tests.view.shared_template_dir.Unassociated class), therefore it
+provokes a UserWarning.
More information about the Checkins
mailing list