ϪfhdZddlZddlmZmZddlmZmZddlm Z m Z m Z dZ GddZ Gd d e jZGd d ZGd dee jZGddee j$Zy)zG Test the interaction between trial and errors logged during test run. N)reactortask)failurelog) _synctestreporterunittestcZ ddz S#t$rtj}Y|SwxYw)z* Return a new, realistic failure. r)ZeroDivisionErrorrFailure)fs =/usr/lib/python3/dist-packages/twisted/trial/test/test_log.py makeFailurers7 A H  OO  Hs  **c|eZdZdZGddZGddeej ZGddeejZ y) Maskz? Hide C{MockTest}s from Trial's automatic test finder. c$eZdZdZdZdZdZy)Mask.FailureLoggingMixincy)z/ Don't log any errors. Nselfs r test_silentz$Mask.FailureLoggingMixin.test_silent sc>tjty)z- Log a single error. Nrerrrrs r test_singlez$Mask.FailureLoggingMixin.test_single%s GGKM "rcxtjttjty)z) Log two errors. Nrrs r test_doublez$Mask.FailureLoggingMixin.test_double+s  GGKM " GGKM "rcHtjtddzy)z8 Log a single error, then fail. r Nrrs rtest_singleThenFailz,Mask.FailureLoggingMixin.test_singleThenFail2s GGKM " HrN)__name__ __module__ __qualname__rrr r"rrrFailureLoggingMixinrs   #  # rr&c eZdZy)Mask.SynchronousFailureLoggingN)r#r$r%rrrSynchronousFailureLoggingr(9s rr)ceZdZdZy)Mask.AsynchronousFailureLoggingc:tjtddS)zC Log an error in an asynchronous callback. rc<tjtSNrrrrzAMask.AsynchronousFailureLogging.test_inCallback..Assww{}7Mr)r deferLaterrrs rtest_inCallbackz/Mask.AsynchronousFailureLogging.test_inCallback=s??7A/MN NrN)r#r$r%r1rrrAsynchronousFailureLoggingr+<s Orr2N) r#r$r%__doc__r&r SynchronousTestCaser)TestCaser2rrrrrs=4 $79U9U O%8(:K:KOrrc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) ObserverTestsz Tests for L{_synctest._LogObserver}, a helper for the implementation of L{SynchronousTestCase.flushLoggedErrors}. chtj|_tj|_yr.)r TestResultresultr _LogObserverobserverrs rsetUpzObserverTests.setUpJs"))+ !..0 rc|jjdtjddd|j|jj gy)zW Test that a standard log message doesn't go anywhere near the result. )z some messager-)messagetimeisErrorsystemN)r<gotEventrA assertEqual getErrorsrs rtest_msgzObserverTests.test_msgNsL ,     002B7rc t}|jjdtjdd|dd|j |jj |gy)zF Test that an observed error gets added to the result rr r?Nr@rArBrCrwhy)rr<rDrArErFrrs r test_errorzObserverTests.test_error\s[ M      002QC8rc0|j|jj}|j|jj g|jt |d|j |djty)zS Check that flushing the observer with no args removes all errors. r rN) rLr< flushErrorsrErFlen assertTruecheckr )rflusheds r test_flushzObserverTests.test_flushmsm --++- 002B7 Wq)  (():;tjtdS)Nz test error)rr RuntimeErrorrs r_makeRuntimeFailurez!ObserverTests._makeRuntimeFailurews|L9::rc |j|j}|jjt dt j dd|d|jj t}|j|jj|g|jt|d|j|djty)zY Check that flushing the observer remove all failures of the given type. rr r?NrIr) rLrVr<rDdictrArNr rErFrOrPrQ)rrrRs rtest_flushByTypezObserverTests.test_flushByTypezs   $ $ &  aQTX  --++,=> 002QC8 Wq)  (():;rsy *'77 'O'OTj9H00j9ZJCJCZ.0L0L.  1B1B  r