/usr/share/pyshared/zope/app/pagetemplate/tests/test_nested.py is in python-zope.app.pagetemplate 3.11.2-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | """Test that nested macro references do the right thing.
"""
__docformat__ = "reStructuredText"
import unittest
from zope.component.testing import PlacelessSetup
from zope.publisher.browser import TestRequest
from zope.browserpage import ViewPageTemplateFile
class Context(object):
pass
class View(object):
def __init__(self, context, request):
self.context = context
self.request = request
EXPECTED = u"""\
<html>
<head>
<title>Example: outer</title>
</head>
<body>
hello
<div>
<div>
inner body slot content
</div>
intermediate body slot stuff
</div>
</body>
</html>
"""
class Test(PlacelessSetup, unittest.TestCase):
def testMacroExtension(self):
# This test demonstrates how macro extension allows a macro to extend
# and re-offer a slot for a client template to fill.
outer = ViewPageTemplateFile('outer.pt')
intermediate = ViewPageTemplateFile('intermediate.pt')
inner = ViewPageTemplateFile('inner.pt')
context = Context()
request = TestRequest()
view = View(context, request)
self.failUnless('outer body slot' in outer(view))
namespace = inner.pt_getContext(view, request)
namespace['outer'] = outer
namespace['intermediate'] = intermediate
result = inner.pt_render(namespace)
self.assertEquals(result, EXPECTED)
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
|