[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/twisted/ftp/tests/t
FailureError is not defined for Twisted 2.1. Also add
Michael Kerrin
michael.kerrin at openapp.biz
Fri Apr 21 03:58:09 EDT 2006
Log message for revision 67197:
FailureError is not defined for Twisted 2.1. Also add
to test when the postCaseCleanup method fails.
Changed:
U Zope3/trunk/src/zope/app/twisted/ftp/tests/test_zopetrial.py
U Zope3/trunk/src/zope/app/twisted/ftp/tests/trial.txt
-=-
Modified: Zope3/trunk/src/zope/app/twisted/ftp/tests/test_zopetrial.py
===================================================================
--- Zope3/trunk/src/zope/app/twisted/ftp/tests/test_zopetrial.py 2006-04-21 00:34:55 UTC (rev 67196)
+++ Zope3/trunk/src/zope/app/twisted/ftp/tests/test_zopetrial.py 2006-04-21 07:58:08 UTC (rev 67197)
@@ -135,9 +135,6 @@
orig_run(self, result)
try:
twisted.trial.util._Janitor().postCaseCleanup()
- except twisted.trial.util.FailureError, e:
- for failure in e.failures:
- result.cleanupErrors(failure)
except:
result.cleanupErrors(twisted.python.failure.Failure(sys.exc_info()))
Modified: Zope3/trunk/src/zope/app/twisted/ftp/tests/trial.txt
===================================================================
--- Zope3/trunk/src/zope/app/twisted/ftp/tests/trial.txt 2006-04-21 00:34:55 UTC (rev 67196)
+++ Zope3/trunk/src/zope/app/twisted/ftp/tests/trial.txt 2006-04-21 07:58:08 UTC (rev 67197)
@@ -159,3 +159,47 @@
<BLANKLINE>
Ran 3 tests with 1 failures and 4 errors in 0.118 seconds.
True
+
+Make sure that errors are handled correctly if the postCaseCleanup method
+fails for what ever reason.
+
+ >>> import twisted.trial.util
+ >>> old_doCleanReactor = twisted.trial.util._Janitor.do_cleanReactor
+ >>> def new_doCleanReactor(cls):
+ ... raise Exception, "Can't clean the reactor"
+ ...
+ >>> twisted.trial.util._Janitor.do_cleanReactor = new_doCleanReactor
+
+ >>> sys.argv = 'test --tests-pattern ^trialtest$ '.split()
+ >>> testrunner.run(defaults)
+ ... # doctest: +NORMALIZE_WHITESPACE
+ Running unit tests:
+ <BLANKLINE>
+ Error in test test_error (trialtest.TestTrialTests)
+ Traceback (most recent call last):
+ ...
+ --- <exception caught here> ---
+ File "...twisted/internet/defer.py", Line NNN, in maybeDeferred
+ result = f(*args, **kw)
+ File "...app/twisted/ftp/tests/trialtest.py", Line NNN, in test_error
+ raise Exception, "this test is a broken trial test :-)"
+ exceptions.Exception: this test is a broken trial test :-)
+ <BLANKLINE>
+ <BLANKLINE>
+ Failure in test test_failure (trialtest.TestTrialTests)
+ Traceback (most recent call last):
+ ...
+ --- <exception caught here> ---
+ File "...twisted/internet/defer.py", Line NNN, in maybeDeferred
+ result = f(*args, **kw)
+ File "...app/twisted/ftp/tests/trialtest.py", Line NNN, in test_failure
+ self.assert_(False, "I am a failed trial test")
+ twisted.trial.unittest.FailTest: I am a failed trial test
+ <BLANKLINE>
+ Ran 3 tests with 1 failures and 1 errors in N.NNN seconds.
+ True
+
+Now un-patch the twisted trial janitor, so that it does actually clean the
+reactor.
+
+ >>> twisted.trial.util._Janitor.do_cleanReactor = old_doCleanReactor
More information about the Zope3-Checkins
mailing list