[Zope-Checkins] SVN: Zope/trunk/lib/python/ Make the new reST tests clearer in intent.

Tres Seaver tseaver at palladion.com
Mon Jul 10 15:07:19 EDT 2006


Log message for revision 69077:
  Make the new reST tests clearer in intent.

Changed:
  U   Zope/trunk/lib/python/Products/ZReST/tests/test_ZReST.py
  U   Zope/trunk/lib/python/reStructuredText/tests/testReST.py

-=-
Modified: Zope/trunk/lib/python/Products/ZReST/tests/test_ZReST.py
===================================================================
--- Zope/trunk/lib/python/Products/ZReST/tests/test_ZReST.py	2006-07-10 17:48:55 UTC (rev 69076)
+++ Zope/trunk/lib/python/Products/ZReST/tests/test_ZReST.py	2006-07-10 19:07:18 UTC (rev 69077)
@@ -64,22 +64,32 @@
         self.assertEqual('<html' in html, True)
         self.assertEqual('<body>' in html, True)
 
-    def testFileInclusion(self):
+    def test_include_directive_raises(self):
         resty = self._makeOne()
         resty.source = 'hello world\n .. include:: /etc/passwd'
         self.assertRaises(NotImplementedError, resty.render)
 
+    def test_raw_directive_disabled(self):
 
-    def testRawPassthrough(self):
+        EXPECTED = '<h1>HELLO WORLD</h1>'
 
         resty = self._makeOne()
-        resty.source = '.. raw:: html\n  <h1>HELLO WORLD</h1>'
-        result = resty.render() # should not fail
+        resty.source = '.. raw:: html\n\n  %s\n' % EXPECTED
+        result = resty.render() # 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_raw_directive_file_directive_raises(self):
+
         resty = self._makeOne()
         resty.source = '.. raw:: html\n  :file: inclusion.txt'
         self.assertRaises(NotImplementedError, resty.render)
 
+    def test_raw_directive_url_directive_raises(self):
+
         resty = self._makeOne()
         resty.source = '.. raw:: html\n  :url: http://www.zope.org/'
         self.assertRaises(NotImplementedError, resty.render)

Modified: Zope/trunk/lib/python/reStructuredText/tests/testReST.py
===================================================================
--- Zope/trunk/lib/python/reStructuredText/tests/testReST.py	2006-07-10 17:48:55 UTC (rev 69076)
+++ Zope/trunk/lib/python/reStructuredText/tests/testReST.py	2006-07-10 19:07:18 UTC (rev 69077)
@@ -82,19 +82,29 @@
         self.assertEquals(output, expected) 
 
 
-    def testFileInclusion(self):
+    def test_include_directive_raises(self):
         source = 'hello world\n .. include:: /etc/passwd'
         self.assertRaises(NotImplementedError, HTML, source)
 
+    def test_raw_directive_disabled(self):
 
-    def testRawPassthrough(self):
+        EXPECTED = '<h1>HELLO WORLD</h1>'
 
-        source = '.. raw:: html\n  <h1>HELLO WORLD</h1>'
-        result = HTML(source)       # don't raise
+        source = '.. raw:: html\n\n  %s\n' % EXPECTED
+        result = HTML(source)       # 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_raw_directive_file_option_raises(self):
+
         source = '.. raw:: html\n  :file: inclusion.txt'
         self.assertRaises(NotImplementedError, HTML, source)
 
+    def test_raw_directive_url_option_raises(self):
+
         source = '.. raw:: html\n  :url: http://www.zope.org'
         self.assertRaises(NotImplementedError, HTML, source)
 



More information about the Zope-Checkins mailing list