Commit 5207d019 authored by Fred Drake's avatar Fred Drake

add tests for on-error handling in macros for errors in slot fillers; errors

in the filler can now be handled by the macro, as intended
parent 98f91792
...@@ -135,9 +135,49 @@ class DTMLTests(unittest.TestCase): ...@@ -135,9 +135,49 @@ class DTMLTests(unittest.TestCase):
expect = util.read_output('DTML3.html') expect = util.read_output('DTML3.html')
util.check_xml(expect, o) util.check_xml(expect, o)
def check_on_error_in_slot_filler(self):
# The `here` isn't defined, so the macro definition is
# expected to catch the error that gets raised.
text = '''\
<div metal:define-macro="foo">
<div tal:on-error="string:eek">
<div metal:define-slot="slot" />
cool
</div>
</div>
<div metal:use-macro="template/macros/foo">
<div metal:fill-slot="slot">
<p tal:content="here/xxx" />
</div>
</div>
'''
self.t.write(text)
aa = util.argv(('one', 'two', 'three', 'four', 'five'))
self.t.__of__(aa)()
def check_on_error_in_slot_default(self):
# The `here` isn't defined, so the macro definition is
# expected to catch the error that gets raised.
text = '''\
<div metal:define-macro="foo">
<div tal:on-error="string:eek">
<div metal:define-slot="slot">
<div tal:content="here/xxx" />
</div>
</div>
</div>
<div metal:use-macro="template/macros/foo">
</div>
'''
self.t.write(text)
aa = util.argv(('one', 'two', 'three', 'four', 'five'))
self.t.__of__(aa)()
def test_suite(): def test_suite():
return unittest.makeSuite(DTMLTests, 'check') return unittest.makeSuite(DTMLTests, 'check')
if __name__=='__main__': if __name__=='__main__':
main() main()
...@@ -769,7 +769,9 @@ class TALInterpreter: ...@@ -769,7 +769,9 @@ class TALInterpreter:
slot = slots.get(slotName) slot = slots.get(slotName)
if slot is not None: if slot is not None:
prev_source = self.sourceFile prev_source = self.sourceFile
try:
self.interpret(slot) self.interpret(slot)
finally:
if self.sourceFile != prev_source: if self.sourceFile != prev_source:
self.engine.setSourceFile(prev_source) self.engine.setSourceFile(prev_source)
self.sourceFile = prev_source self.sourceFile = prev_source
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment