r46831 - Finally write a failing test.

mithrandi-TA+aISz0psMTMxyoc4vAAJOcrHinNvQL0E9HWUfgJXw@public.gmane.org
Newsgroups gmane.comp.python.twisted.commits
Message-ID <[email protected]>
Author: mithrandi
Date: Thu Feb 18 21:26:26 2016
New Revision: 46831

Modified:
   branches/suppress-error-8192/twisted/web/test/test_util.py

Log:
Finally write a failing test.

Modified: branches/suppress-error-8192/twisted/web/test/test_util.py
==============================================================================
--- branches/suppress-error-8192/twisted/web/test/test_util.py	(original)
+++ branches/suppress-error-8192/twisted/web/test/test_util.py	Thu Feb 18 21:26:26 2016
@@ -7,8 +7,10 @@
 
 from __future__ import absolute_import, division
 
+import gc
+
 from twisted.python.failure import Failure
-from twisted.trial.unittest import TestCase
+from twisted.trial.unittest import SynchronousTestCase, TestCase
 from twisted.internet import defer
 from twisted.python.compat import _PY3, intToBytes, networkString
 from twisted.web import resource, util
@@ -316,7 +318,7 @@
 
 
 
-class DeferredResourceTests(TestCase):
+class DeferredResourceTests(SynchronousTestCase):
     """
     Tests for L{DeferredResource}.
     """
@@ -344,3 +346,18 @@
         deferredResource = DeferredResource(defer.succeed(result))
         deferredResource.render(request)
         self.assertEqual(rendered, [result])
+
+
+    def test_renderNoFailure(self):
+        """
+        If the L{Deferred} fails, L{DeferredResource} does not cause an
+        unhandled error to be logged.
+        """
+        request = DummyRequest([])
+        deferredResource = DeferredResource(
+            defer.fail(Failure(RuntimeError())))
+        deferredResource.render(request)
+        del deferredResource
+        gc.collect()
+        errors = self.flushLoggedErrors(RuntimeError)
+        self.assertEqual(errors, [])
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.