Ϫf dZddlmZddlmZddlmZmZddlm Z ddl m Z ddl m Z ddlmZdd lmZdd lmZdd lmZd d lmZddZGdde ZdZgdZy)z0 General helpers for L{twisted.web} unit tests. ) annotations)Type)Deferredsucceed)SynchronousTestCase)server) flattenString)FlattenerError)Request) IResource) Flattenable) DummyRequestc*|j|}t|tr,|j||j t dS|t jur'|jr t dS|jStd|)NzUnexpected return value: ) render isinstancebyteswritefinishrr NOT_DONE_YETfinished notifyFinish ValueError)resourcerequestresults 8/usr/lib/python3/dist-packages/twisted/web/test/_util.py_renderrs} __W %F&%  ft} 6&& &   4= '') )4VJ?@@c(eZdZdZddZddZddZy) FlattenTestCasezH A test case that assists with testing L{twisted.web._flatten}. cRdfd }td|}|j||S)zS Assert that a root element, when flattened, is equal to a string. c,j||S)N) assertEqual)rselftargets rcheckz/FlattenTestCase.assertFlattensTo..check/s   VV ,MrN)rrreturnr)r addCallback)r%rootr&r'ds` ` rassertFlattensToz FlattenTestCase.assertFlattensTo*s'  +46 ercD|j|j||S)a Assert that a root element, when flattened, is equal to a string, and performs no asynchronus Deferred anything. This version is more convenient in tests which wish to make multiple assertions about flattening, since it can be called multiple times without having to add multiple callbacks. @return: the result of rendering L{root}, which should be equivalent to L{target}. @rtype: L{bytes} )successResultOfr,)r%r*r&s rassertFlattensImmediatelyz)FlattenTestCase.assertFlattensImmediately7s"##D$9$9$$GHHrc|j|j|dt}|j|jj |y)zQ Assert flattening a root element raises a particular exception. rN)failureResultOfr,r assertIsInstancevalue _exception)r%r*exnfailures rassertFlatteningRaisesz&FlattenTestCase.assertFlatteningRaisesFs=&&t'<'rPsN#46.,$*,' A&=)&=R1" Hr