Skip to content

Commit

Permalink
Forward port tests for DTML not exposing ReST file inclusion.
Browse files Browse the repository at this point in the history
  • Loading branch information
tseaver committed Jul 10, 2006
1 parent 9b0fb51 commit db75f5f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/testDTML.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,43 @@ def test_fmt(self):
spam='<a href="spam">\nfoo bar')
self.assertEqual(res,expected)

def test_fmt_reST_include_directive_raises(self):
source = '.. include:: /etc/passwd'
html = self.doc_class('<dtml-var name="foo" fmt="restructured-text">')
html._vars['foo'] = source
self.assertRaises(NotImplementedError, html)

def test_fmt_reST_raw_directive_disabled(self):

EXPECTED = '<h1>HELLO WORLD</h1>'

source = '.. raw:: html\n\n %s\n' % EXPECTED
html = self.doc_class('<dtml-var name="foo" fmt="restructured-text">')
html._vars['foo'] = source

result = html() # don't raise, but don't work either
self.failIf(EXPECTED in result)

self.failUnless("&quot;raw&quot; directive disabled" in result)
from cgi import escape
self.failUnless(escape(EXPECTED) in result)

def test_fmt_reST_raw_directive_file_option_raises(self):

source = '.. raw:: html\n :file: inclusion.txt'
html = self.doc_class('<dtml-var name="foo" fmt="restructured-text">')
html._vars['foo'] = source

self.assertRaises(NotImplementedError, html, source)

def test_fmt_reST_raw_directive_url_option_raises(self):

source = '.. raw:: html\n :url: http://www.zope.org'
html = self.doc_class('<dtml-var name="foo" fmt="restructured-text">')
html._vars['foo'] = source

self.assertRaises(NotImplementedError, html, source)

def testPropogatedError(self):

class foo:
Expand Down

0 comments on commit db75f5f

Please sign in to comment.