ϪfqdZddlZddlmZddlmZmZddlmZddl m Z ddl m Z m Z ddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZmZm Z ddl!m"Z"m#Z#ddl$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1ddl2m3Z3ee4dZ5GddeZ6GddeZ7GddeZ8GddZ9Gdd ee9Z:Gd!d"ee9Z;Gd#d$ee9Z<Gd%d&ee9Z=Gd'd(e1Z>Gd)d*e1Z?Gd+d,e'Z@Gd-d.e'ZAGd/d0e'ZBGd1d2ZCee"Gd3d4e3ZDGd5d6eZEy)7z# Tests for L{twisted.web.template} N)StringIO)ListOptional) implementer) verifyObject)Deferredsucceed)EventLoggingObserver)globalLogPublisher)Failure)FilePath)TestCase)suppress)UnexposedMethodError)FlattenerErrorMissingRenderMethodMissingTemplateLoader)IRequestITemplateLoader) NOT_DONE_YET) Element FlattenableTag TagLoaderXMLFile XMLString renderElementrenderertags)FlattenTestCase) DummyRequesthPassing filenames or file objects to XMLFile is deprecated since Twisted 12.1. Pass a FilePath instead.)categorymessagec8eZdZdZddZddZddZddZddZy) TagFactoryTestszO Tests for L{_TagFactory} through the publicly-exposed L{tags} object. Nc\tj}|j|jdy)z= HTML tags can be retrieved through C{tags}. aN)rr( assertEqualtagNameselftags @/usr/lib/python3/dist-packages/twisted/web/test/test_template.pytest_lookupTagzTagFactoryTests.test_lookupTag4s!ff c*c\tj}|j|jdy)zj Twisted supports the latest and greatest HTML tags from the HTML5 specification. videoN)rr2r)r*r+s r.test_lookupHTML5Tagz#TagFactoryTests.test_lookupHTML5Tag;s! jj g.r0c\tj}|j|jdy)z To support transparent inclusion in templates, there is a special tag, the transparent tag, which has no name of its own but is accessed through the "transparent" attribute. N)r transparentr)r*r+s r.test_lookupTransparentTagz)TagFactoryTests.test_lookupTransparentTagCs#  b)r0cD|jtttdy)zv Invalid tags which are not part of HTML cause AttributeErrors when accessed through C{tags}. invalidN assertRaisesAttributeErrorgetattrrr,s r.test_lookupInvalidTagz%TagFactoryTests.test_lookupInvalidTagLs .'4Cr0cD|jtttdy)z As a special case, the tag is simply not available through C{tags} or any other part of the templating machinery. xmpNr:���r>���s��� r.���test_lookupXMPzTagFactoryTests.test_lookupXMPS���s���� � .'4?r0���returnN) __name__ __module__ __qualname____doc__r/���r3���r7���r?���rB����r0���r.���r&���r&���/���s"����+/*D@r0���r&���c�������������������P����e�Zd�ZdZd dZd dZd dZd dZd dZd dZ d d Z d d Z y) ElementTestsz5 Tests for the awesome new L{Element} class. Nc���������������������t���������������}|�j������������������t��������|j������������������d������}|�j ������������������|j ������������������|�������y)zr L{Element.render} raises L{MissingTemplateLoader} if the C{loader} attribute is L{None}. N)r���r;���r���renderassertIdenticalelementr,���rO���errs��� r.���test_missingTemplateLoaderz'ElementTests.test_missingTemplateLoader`���s8���� �) 5w~~tL S[['2r0���c����������� ������t�����G�d�dt���������������}|�j������������������dt��������t���������|��������������������������y)zT A L{MissingTemplateLoader} instance can be repr()'d without error. c�����������������������e�Zd�ZdefdZy)FElementTests.test_missingTemplateLoaderRepr.<locals>.PrettyReprElementrD���c����������������������yNPretty Repr ElementrI���r>���s��� r.���__repr__zOElementTests.test_missingTemplateLoaderRepr.<locals>.PrettyReprElement.__repr__o�������,r0���NrE���rF���rG���strrY���rI���r0���r.���PrettyReprElementrU���n������� -#� -r0���r]���rX���N)r���assertInreprr���)r,���r]���s��� r.���test_missingTemplateLoaderReprz+ElementTests.test_missingTemplateLoaderRepri���s0����  -� -� !4(=>O>Q(R#S r0���c���������������������t���������������}|�j������������������t��������|j������������������d������}|�j ������������������|j ������������������|�������|�j ������������������|j������������������d�������y)z When called with the name which is not associated with a render method, L{Element.lookupRenderMethod} raises L{MissingRenderMethod}. fooN)r���r;���r���lookupRenderMethodrN���rO���r)��� renderNamerP���s��� r.���test_missingRendererMethodz'ElementTests.test_missingRendererMethodv���sO���� �) 3W5O5OQVW S[['2 /r0���c����������������������G�d�dt���������������}t��������t���������|�������d������������}|�j������������������d|�������|�j������������������d|�������y)zR A L{MissingRenderMethod} instance can be repr()'d without error. c�����������������������e�Zd�ZdefdZy)DElementTests.test_missingRenderMethodRepr.<locals>.PrettyReprElementrD���c����������������������yrW���rI���r>���s��� r.���rY���zMElementTests.test_missingRenderMethodRepr.<locals>.PrettyReprElement.__repr__���rZ���r0���Nr[���rI���r0���r.���r]���ri������r^���r0���r]���expectedMethodrX���N)r���r`���r���r_���)r,���r]���ss��� r.���test_missingRenderMethodReprz)ElementTests.test_missingRenderMethodRepr���sE����  -� -� $%6%8:JK L +Q/ &*r0���c����������������������G�d�dt���������������}�|�������j������������������d������}|�j�������������������|dt��������j������������������������d�������y)z When called with the name of a defined render method, L{Element.lookupRenderMethod} returns that render method. c�������������������0����e�Zd�Zedee���dedefd�������Zy)BElementTests.test_definedRenderer.<locals>.ElementWithRenderMethodrequestr-���rD���c����������������������y)NbarrI���r,���rq���r-���s��� r.���rc���zFElementTests.test_definedRenderer.<locals>.ElementWithRenderMethod.foo���s����r0���N) rE���rF���rG���r���r���r���r���r���rc���rI���r0���r.���ElementWithRenderMethodrp������s.����  8H#5� C� K� � r0���ru���rc���Nrs���)r���rd���r)���r���br)r,���ru���rc���s��� r.���test_definedRendererz!ElementTests.test_definedRenderer���s>����  g�  �&'::5A T477+U3r0���c���������������������t��������t���������������G�d�d��������������G�fddt��������������}�|�������}|�j������������������|j ������������������d������dg�������y)zi L{Element.render} loads a document from the C{loader} attribute and returns it. c�����������������������e�Zd�Zdee���fdZy)0ElementTests.test_render.<locals>.TemplateLoaderrD���c���������������������dgS�)NresultrI���r>���s��� r.���loadz5ElementTests.test_render.<locals>.TemplateLoader.load���s ���� z!r0���N)rE���rF���rG���r���r���r}���rI���r0���r.���TemplateLoaderrz������s���� "d;/� "r0���r~���c�����������������������e�Zd�Z�W���������Zy)-ElementTests.test_render.<locals>.StubElementN)rE���rF���rG���loader)r~���s���r.��� StubElementr������s ����#%Fr0���r���Nr|���)r���r���r���r)���rM���)r,���r���rO���r~���s��� @r.��� test_renderzElementTests.test_render���sQ���� � _ % "� "� & " &'� &�- -z:r0���c���������������������|�j������������������t��������t��������������}t��������j������������������dk\��r|�j ������������������t ��������|������d�������y|�j ������������������t ��������|������d�������y)z If the L{renderer} decorator is called without any arguments, it will raise a comprehensible exception. )��� ���z=Expose.__call__() missing 1 required positional argument: 'f'z6__call__() missing 1 required positional argument: 'f'N)r;��� TypeErrorr���sys version_infor)���r\���)r,���tes��� r.���test_misuseRendererz ElementTests.test_misuseRenderer���sV���� �  y( 3   w &   BX �   BQ r0���c�����������������P����|�j������������������t��������t��������j������������������dd�������y)z Called directly, without a default, L{renderer.get} raises L{UnexposedMethodError} when it cannot find a renderer. N notARenderer)r;���r���r���getr>���s��� r.���test_renderGetDirectlyErrorz(ElementTests.test_renderGetDirectlyError���s���� � . dNSr0���rC���) rE���rF���rG���rH���rR���ra���rf���rm���rw���r���r���r���rI���r0���r.���rK���rK���[���s0����3  0 + 4;" Tr0���rK���c�������������������H����e�Zd�ZdZddZddZege_��������ddZege_��������y)XMLFileReprTestszB Tests for L{twisted.web.template.XMLFile}'s C{__repr__}. Nc�����������������j����t��������d������}|�j������������������d|dt��������t��������|�������������������y)zK An L{XMLFile} with a L{FilePath} returns a useful repr(). /tmp/fake.xml <XMLFile of >N)r ���r)���r`���r���)r,���paths��� r.��� test_filePathzXMLFileReprTests.test_filePath���s0�����( <xq14 3FGr0���c�����������������X����d}|�j������������������d|dt��������t��������|�������������������y)zH An L{XMLFile} with a filename returns a useful repr(). r���r���r���N)r)���r`���r���)r,���fnames��� r.��� test_filenamezXMLFileReprTests.test_filename���s+�����  <y2D4HIr0���c�����������������j����t��������d������}|�j������������������d|dt��������t��������|�������������������y)zK An L{XMLFile} with a file object returns a useful repr(). znot xmlr���r���N)r���r)���r`���r���)r,���fobjs��� r.��� test_filezXMLFileReprTests.test_file���s0����� " <xq14 3FGr0���rC���) rE���rF���rG���rH���r���r���_xmlFileSuppressr���r���rI���r0���r.���r���r������s3����HJ�//MH�++Ir0���r���c�������������������L����e�Zd�ZU�eed<��� �dZ �defdZddZddZ e ge _ ��������y) XMLLoaderTestsMixin deprecatedUse<p>Hello, world.</p>rD���c���������������������t���������N)NotImplementedErrorr>���s��� r.��� loaderFactoryz!XMLLoaderTestsMixin.loaderFactory���s����!!r0���Nc�����������������*���t��������|�t��������������sJ�|�j�������������������������}|j�������������������������\��}t��������|t��������������sJ�|�j ������������������|�j������������������g������}|�j ������������������rP|�j������������������t��������|������d�������|�j������������������|d���d���t���������������|�j������������������|d���d���d�������n|�j������������������t��������|������d�������|�j������������������|j������������������d�������|�j������������������|j������������������dg�������y ) zQ Verify that the loader returns a tag with the correct children. )offendingFunctions���r���r#���r$���r"���p Hello, world.N) isinstancer���r���r}���r��� flushWarningsr���r)���lenDeprecationWarningr*���children)r,���r���r-���warningss��� r.��� test_loadzXMLLoaderTestsMixin.test_load���s�����$)))##%#s###%%$:L:L9M%N      S]A .   Xa[46H I    I&K  �   S]A . c* '89r0���c���������������������t��������|�t��������������sJ�|�j�������������������������}|j�������������������������}|j�������������������������}|�j ������������������||�������y)zd If {load()} can be called on a loader twice the result should be the same. N)r���r���r���r}���r)���)r,���r���tags1tags2s��� r.���test_loadTwicez"XMLLoaderTestsMixin.test_loadTwice ��sH���� �$)))##%   &r0���rC���) rE���rF���rG���bool__annotations__templateStringr���r���r���r���r���r���rI���r0���r.���r���r������s<���� �,N"�":0 '� 00Nr0���r���c������������������� ����e�Zd�ZdZdZdefdZy)XMLStringLoaderTestsz5 Tests for L{twisted.web.template.XMLString} FrD���c�����������������,����t��������|�j������������������������S�)zS @return: an L{XMLString} constructed with C{self.templateString}. )r���r���r>���s��� r.���r���z"XMLStringLoaderTests.loaderFactory��s�����,,--r0���NrE���rF���rG���rH���r���r���r���rI���r0���r.���r���r�����s�����M.�.r0���r���c������������������� ����e�Zd�ZdZdZdefdZy)XMLFileWithFilePathTestszJ Tests for L{twisted.web.template.XMLFile}'s L{FilePath} support. FrD���c���������������������t��������|�j�������������������������������}|j������������������|�j������������������j ������������������d�������������t ��������|������S�)z @return: an L{XMLString} constructed with a L{FilePath} pointing to a file that contains C{self.templateString}. utf8)r ���mktemp setContentr���encoder���r,���fps��� r.���r���z&XMLFileWithFilePathTests.loaderFactory,��s;���� �dkkm $ d))0089r{r0���Nr���rI���r0���r.���r���r���%��s�����M�r0���r���c������������������� ����e�Zd�ZdZdZdefdZy)XMLFileWithFileTestszU Tests for L{twisted.web.template.XMLFile}'s deprecated file object support. TrD���c�����������������>����t��������t��������|�j������������������������������S�)z{ @return: an L{XMLString} constructed with a file object that contains C{self.templateString}. )r���r���r���r>���s��� r.���r���z"XMLFileWithFileTests.loaderFactory=��s���� �x 3 3455r0���Nr���rI���r0���r.���r���r���6��s�����M6�6r0���r���c������������������� ����e�Zd�ZdZdZdefdZy)XMLFileWithFilenameTestszR Tests for L{twisted.web.template.XMLFile}'s deprecated filename support. TrD���c���������������������t��������|�j�������������������������������}|j������������������|�j������������������j ������������������d�������������t ��������|j ������������������������S�)z @return: an L{XMLString} constructed with a filename that points to a file containing C{self.templateString}. r���)r ���r���r���r���r���r���r���r���s��� r.���r���z&XMLFileWithFilenameTests.loaderFactoryL��s@���� �dkkm $ d))0089rwwr0���Nr���rI���r0���r.���r���r���E��s�����M � r0���r���c�����������������������e�Zd�ZdZddZddZddZddZddZddZ dd Z dd Z dd Z dd Z dd ZddZddZddZddZddZddZddZy)FlattenIntegrationTestsz[ Tests for integration between L{Element} and L{twisted.web._flatten.flatten}. Nc�����������������d����g�d}|D�]'��}|�j������������������t��������t��������|������������|�������)�y)z Given a series of parsable XML strings, verify that L{twisted.web._flatten.flatten} will flatten the L{Element} back to the input when sent on a round trip. )���<p>Hello, world.</p>s���<p><!-- hello, world --></p>s ���<p><![CDATA[Hello, world.]]></p>sB���<test1 xmlns:test2="urn:test2"><test2:test3></test2:test3></test1>s0���<test1 xmlns="urn:test2"><test3></test3></test1> ���<p>☃</p>r���N)assertFlattensImmediatelyr���r���)r,��� fragmentsxmls��� r.���test_roundTripz&FlattenIntegrationTests.test_roundTrip\��s5����  �� PC  * *7)C.+I3 O Pr0���c�����������������R����t��������t��������d������������}|�j������������������|d�������y)zx When flattening an HTML entity, it should flatten out to the utf-8 representation if possible. z<p>&#9731;</p>r���r���Nr���r���r���r,���rO���s��� r.���test_entityConversionz-FlattenIntegrationTests.test_entityConversionm��s%���� �+;!<= &&w0FGr0���c�����������������@����|�j������������������t���������������t���������������y)zk Rendering an Element without a loader attribute raises the appropriate exception. N)assertFlatteningRaisesr���r���r>���s��� r.���rR���z2FlattenIntegrationTests.test_missingTemplateLoaderu��s���� � ##GI/DEr0���c�����������������Z����t��������t��������d������������}|�j������������������|t���������������y)z Flattening an L{Element} with a C{loader} which has a tag with a render directive fails with L{FlattenerError} if there is no available render method to satisfy that directive. zy <p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1" t:render="unknownMethod" /> r���N)r���r���r���r���r���s��� r.���test_missingRenderMethodz0FlattenIntegrationTests.test_missingRenderMethod|��s.���� �  � ##G-@Ar0���c�����������������R����t��������t��������d������������}|�j������������������|d�������y)zw A C{transparent} element should be eliminated from the DOM and rendered as only its children. zk<t:transparent xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1">Hello, world.</t:transparent>r��� ���Hello, world.Nr���r���s��� r.���test_transparentRenderingz1FlattenIntegrationTests.test_transparentRendering��s.���� �# � &&w0@Ar0���c�����������������R����t��������t��������d������������}|�j������������������|d�������y)z~ An Element with an attr tag renders the vaule of its attr tag as an attribute of its containing tag. z<a xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"><t:attr name="href">http://example.com</t:attr>Hello, world.</a>r���s.���<a href="http://example.com">Hello, world.</a>Nr���r���s��� r.���test_attrRenderingz*FlattenIntegrationTests.test_attrRendering��s1���� � � && F r0���c�����������������r����|�j������������������t��������d������D�cg�c] ��}t��������d�������c}d�������yc�c}w�)z When rendering a large number of already-fired Deferreds we should not encounter any recursion errors or stack-depth issues. ���xs���xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxN)r���ranger ���)r,���is��� r.���!test_synchronousDeferredRecursionz9FlattenIntegrationTests.test_synchronousDeferredRecursion��s*���� � &&eCj'I 'I:V'Is���4c�����������������:����|�j������������������t��������t��������d�������y)z{ A template with a toplevel C{attr} tag will not load; it will raise L{AssertionError} if you try. z<t:attr xmlns:t='http://twistedmatrix.com/ns/twisted.web.template/0.1' name='something' >hello</t:attr> Nr;���AssertionErrorr���r>���s��� r.���test_errorToplevelAttrz.FlattenIntegrationTests.test_errorToplevelAttr��s���� �     r0���c�����������������:����|�j������������������t��������t��������d�������y)z A template with an C{attr} tag with no C{name} attribute will not load; it will raise L{AssertionError} if you try. z{<html><t:attr xmlns:t='http://twistedmatrix.com/ns/twisted.web.template/0.1' >hello</t:attr></html>Nr���r>���s��� r.���test_errorUnnamedAttrz-FlattenIntegrationTests.test_errorUnnamedAttr��s���� �    & r0���c�����������������t����d}t��������t��������|������������}|�j������������������||j������������������d�������������y)z If the parser sees a prefix it doesn't recognize on an attribute, it will pass it on through to serialization. z}<hello:world hello:sample="testing" xmlns:hello="http://made-up.example.com/ns/not-real">This is a made-up tag.</hello:world>r���r���N)r���r���assertFlattensTor���)r,���theInputrO���s��� r.���test_lenientPrefixBehaviorz2FlattenIntegrationTests.test_lenientPrefixBehavior��s6����  3�  �8!45 gxv'>?r0���c�����������������j�����G�d�dt���������������}�|t��������d������������}|�j������������������|d�������y)zi An Element with a render method which returns a Deferred will render correctly. c�������������������0����e�Zd�Zedee���dedefd�������Zy)HFlattenIntegrationTests.test_deferredRendering.<locals>.RenderfulElementrq���r-���rD���c���������������������t��������d������S�Nr���)r ���rt���s��� r.��� renderMethodzUFlattenIntegrationTests.test_deferredRendering.<locals>.RenderfulElement.renderMethod��s�����//r0���N rE���rF���rG���r���r���r���r���r���r���rI���r0���r.���RenderfulElementr�����s1����  0'1 08; 0 0� 0r0���r��� <p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1" t:render="renderMethod"> Goodbye, world. </p> r���r���Nr���r,���r���rO���s��� r.���test_deferredRenderingz.FlattenIntegrationTests.test_deferredRendering��s:����  0w� 0�#   � &&w0@Ar0���c�����������������P�����G�d�dt���������������}|�j�������������������|�������d�������y)z If there is a non-None loader attribute on the class of an Element instance but none on the instance itself, the class attribute is used. c�����������������������e�Zd�Z�ed������Zy)EFlattenIntegrationTests.test_loaderClassAttribute.<locals>.SubElementr���N)rE���rF���rG���r���r���rI���r0���r.��� SubElementr����s ����56Fr0���r��r���N)r���r���)r,���r��s��� r.���test_loaderClassAttributez1FlattenIntegrationTests.test_loaderClassAttribute��s#����  7� 7� &&z|5LMr0���c�����������������t����g��G�fddt���������������}�|t��������d������������}|�j������������������|d�������y)z An Element with a valid render directive has that directive invoked and the result added to the output. c�������������������6����e�Zd�Zedee���dedef�fd �������Zy)IFlattenIntegrationTests.test_directiveRendering.<locals>.RenderfulElementrq���r-���rD���c�����������������:����j������������������|�|f��������|d������S�r���)append)r,���rq���r-���renderss��� r.���r���zVFlattenIntegrationTests.test_directiveRendering.<locals>.RenderfulElement.renderMethod��s �����g/?++r0���Nr���)r ��s���r.���r���r����s2����  ,'1 ,8; , ,� ,r0���r���x <p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1" t:render="renderMethod" /> r���r���Nr���)r,���r���rO���r ��s��� @r.���test_directiveRenderingz/FlattenIntegrationTests.test_directiveRendering���sB���� � ,w� ,�#  � &&w0GHr0���c�����������������j�����G�d�dt���������������}�|t��������d������������}|�j������������������|d�������y)z An Element with a render method which omits the containing tag successfully removes that tag from the output. c�������������������0����e�Zd�Zedee���dedefd�������Zy)TFlattenIntegrationTests.test_directiveRenderingOmittingTag.<locals>.RenderfulElementrq���r-���rD���c����������������������yr���rI���rt���s��� r.���r���zaFlattenIntegrationTests.test_directiveRenderingOmittingTag.<locals>.RenderfulElement.renderMethod ��s�����'r0���Nr���rI���r0���r.���r���r����s1����  ''1 '8; ' '� 'r0���r���r���r���r���Nr���r���s��� r.���"test_directiveRenderingOmittingTagz:FlattenIntegrationTests.test_directiveRenderingOmittingTag��s:����  'w� '�#   � &&w0@Ar0���c�����������������j�����G�d�dt���������������}�|t��������d������������}|�j������������������|d�������y)t An Element which is returned by the render method of another Element is rendered properly. c�������������������0����e�Zd�Zedee���dedefd�������Zy)UFlattenIntegrationTests.test_elementContainingStaticElement.<locals>.RenderfulElementrq���r-���rD���c�����������������8�����|t��������t��������d������������������S�)Nz<em>Hello, world.</em>r���)r���r���rt���s��� r.���r���zbFlattenIntegrationTests.test_elementContainingStaticElement.<locals>.RenderfulElement.renderMethod9��s�����7)4L*MNOOr0���Nr���rI���r0���r.���r���r��8��s6����  P'1 P8; P P� Pr0���r���r ��r���s���<p><em>Hello, world.</em></p>Nr���r���s��� r.���#test_elementContainingStaticElementz;FlattenIntegrationTests.test_elementContainingStaticElement2��s<����  Pw� P�#  � &&w0PQr0���c�����������������j�����G�d�dt���������������}�|t��������d������������}|�j������������������|d�������y)r��c�������������������0����e�Zd�Zedee���dedefd�������Zy)HFlattenIntegrationTests.test_elementUsingSlots.<locals>.RenderfulElementrq���r-���rD���c�����������������&����|j������������������d������S�)Nzworld.)test2) fillSlotsrt���s��� r.���r���zUFlattenIntegrationTests.test_elementUsingSlots.<locals>.RenderfulElement.renderMethodP��s�����}}8}44r0���Nr���rI���r0���r.���r���r��O��s1����  5'1 58; 5 5� 5r0���r���z<p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1" t:render="renderMethod"><t:slot name="test1" default="Hello, " /><t:slot name="test2" /></p>r���r���Nr���r���s��� r.���test_elementUsingSlotsz.FlattenIntegrationTests.test_elementUsingSlotsI��s:����  5w� 5�# � &&w0GHr0���c����������������������G�fddt���������������}�G�d�dt����������������|t��������d������������}|�j������������������|d�������y) z Directives in the document factory of an Element returned from a render method of another Element are satisfied from the correct object: the "inner" Element. c�������������������6����e�Zd�Zedee���dedef�fd �������Zy)RFlattenIntegrationTests.test_elementContainingDynamicElement.<locals>.OuterElementrq���r-���rD���c�����������������4�����|�t��������d������������������S�)Nz <t:ignored xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1" t:render="innerMethod" /> r���)r���)r,���rq���r-��� InnerElements��� r.��� outerMethodz^FlattenIntegrationTests.test_elementContainingDynamicElement.<locals>.OuterElement.outerMethodi��s%���� (  � r0���N) rE���rF���rG���r���r���r���r���r���r#��)r"��s���r.��� OuterElementr ��h��s/����  8H+=� C� K� � r0���r$��c�������������������0����e�Zd�Zedee���dedefd�������Zy)RFlattenIntegrationTests.test_elementContainingDynamicElement.<locals>.InnerElementrq���r-���rD���c����������������������yr���rI���rt���s��� r.��� innerMethodz^FlattenIntegrationTests.test_elementContainingDynamicElement.<locals>.InnerElement.innerMethodx��s����&r0���N) rE���rF���rG���r���r���r���r���r���r(��rI���r0���r.���r"��r&��w��s.����  '8H+=� 'C� 'K� '� 'r0���r"��zw <p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1" t:render="outerMethod" /> r���r���Nr���)r,���r$��rO���r"��s��� @r.���$test_elementContainingDynamicElementz<FlattenIntegrationTests.test_elementContainingDynamicElementa��sG���� 7�  '7� ' �  � &&w0GHr0���c���������������������t��������d�������G�fddt����������������������}��������}|�j������������������|d�������|�j������������������|d�������|�j������������������|d�������y)z Rendering the output of a loader, or even the same element, should return different output each time. z<p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1"><t:transparent t:render="classCounter" /> <t:transparent t:render="instanceCounter" /></p>c�������������������h����e�Zd�ZdZdZW�Zedee���de de f�fd �������Z edee���de de fd�������Z y)HFlattenIntegrationTests.test_sameLoaderTwice.<locals>.DestructiveElementr���rq���r-���rD���c�����������������d����xj�������������������dz ��c_����������|t��������j�������������������������������S�Nr���)countr\���)r,���rq���r-���DestructiveElements��� r.��� classCounterzUFlattenIntegrationTests.test_sameLoaderTwice.<locals>.DestructiveElement.classCounter��s-�����#((A-(3177899r0���c�����������������b����|�xj�������������������dz ��c_����������|t��������|�j�������������������������������S�r.��) instanceCountr\���rt���s��� r.���instanceCounterzXFlattenIntegrationTests.test_sameLoaderTwice.<locals>.DestructiveElement.instanceCounter��s+�����""a'"3t11233r0���N) rE���rF���rG���r/��r3��r���r���r���r���r���r���r1��r4��)r0�� sharedLoaders���r.���r0��r,����sr����EM!F  :'1 :8; : :� : � 4'1 48; 4 4� 4r0���r0��s ���<p>1 1</p>s ���<p>2 2</p>s ���<p>3 1</p>N)r���r���r���)r,���e1e2r0��r5��s��� @@r.���test_sameLoaderTwicez,FlattenIntegrationTests.test_sameLoaderTwice��sb���� �!   4� 4&� !  ! &&r=9 &&r=9 &&r=9r0���rC���)rE���rF���rG���rH���r���r���rR���r���r���r���r���r���r���r���r���r��r ��r��r��r��r)��r8��rI���r0���r.���r���r���V��sp���� P"HFB B "W     @B2 NI2B2R.I0#IJ#:r0���r���c�������������������0����e�Zd�ZdZddZddZddZddZy)TagLoaderTestsz! Tests for L{TagLoader}. Nc�����������������J����t��������t��������j������������������d������������|�_��������y�)Ntest)r���r���r���r���r>���s��� r.���setUpzTagLoaderTests.setUp��s����v/ r0���c�����������������V����|�j������������������t��������t��������|�j�������������������������������y)zJ An instance of L{TagLoader} provides L{ITemplateLoader}. N) assertTruer���r���r���r>���s��� r.���test_interfacezTagLoaderTests.test_interface��s�����  _dkkBCr0���c�����������������`����|�j������������������|�j������������������j�������������������������t���������������y)zK L{TagLoader.load} returns a list, per L{ITemplateLoader}. N)assertIsInstancer���r}���listr>���s��� r.���test_loadsListzTagLoaderTests.test_loadsList��s!����� dkk..0$7r0���c�����������������R����t��������|�j������������������������}|�j������������������|d�������y)z L{TagLoader} can be used in an L{Element}, and flattens as the tag used to construct the L{TagLoader} would flatten. s ���<i>test</i>N)r���r���r���)r,���es��� r.��� test_flattenzTagLoaderTests.test_flatten��s"���� � DKK  &&q.9r0���rC���)rE���rF���rG���rH���r=��r@��rD��rG��rI���r0���r.���r:��r:����s����0D 8 :r0���r:��c������������������� ����e�Zd�ZdZ�ed������Zy) TestElementz: An L{Element} that can be rendered successfully. zS<p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1">Hello, world.</p>N)rE���rF���rG���rH���r���r���rI���r0���r.���rI��rI����s����� Fr0���rI��c�������������������6����e�Zd�ZdZ�ed������ZddededdfdZy) TestFailureElementz An L{Element} that can be used in place of L{FailureElement} to verify that L{renderElement} can render failures properly. zO<p xmlns:t="http://twistedmatrix.com/ns/twisted.web.template/0.1">I failed.</p>Nfailurer���rD���c���������������������||�_���������y�r���)rL��)r,���rL��r���s��� r.���__init__zTestFailureElement.__init__��s ���� r0���r���) rE���rF���rG���rH���r���r���r ���objectrN��rI���r0���r.���rK��rK����s2���� � F ��4�r0���rK��c�������������������&����e�Zd�ZdZdee���ddfdZy)FailingElementz< An element that raises an exception when rendered. rq���rD���r���c���������������������d}d}||z���S�)N*���r���rI���)r,���rq���r(���bs��� r.���rM���zFailingElement.render��s����  q&r0���N)rE���rF���rG���rH���r���r���rM���rI���r0���r.���rQ��rQ����s����hx0�]�r0���rQ��c�����������������������e�Zd�ZdZdZy)FakeSitezL A minimal L{Site} object that we can use to test displayTracebacks FN)rE���rF���rG���rH���displayTracebacksrI���r0���r.���rV��rV����s�����r0���rV��c�������������������$�����e�Zd�ZdZd�fd Z�xZS�)DummyRenderRequestz A dummy request object that has a C{site} attribute. This does not implement the full IRequest interface, but enough of it for this test suite. c�����������������D����t���������|���dg�������t���������������|�_��������y�)Nr0���)superrN��rV��site)r,��� __class__s��� r.���rN��zDummyRenderRequest.__init__��s���� #J r0���rC���)rE���rF���rG���rH���rN�� __classcell__)r]��s���@r.���rY��rY����s�����r0���rY��c�������������������r����e�Zd�ZdZd dZded���fdZded���fdZded���fdZded���fdZ ded���fd Z y) RenderElementTestsz Test L{renderElement} rD���Nc�����������������"����t���������������|�_��������y)z8 Set up a common L{DummyRenderRequest}. N)rY��rq���r>���s��� r.���r=��zRenderElementTests.setUp ��s�����*+ r0���c����������������������t���������������}�j������������������j�������������������������}dt��������ddf�fd }|j ������������������|��������j ������������������t ��������t���������j������������������|�������������|S�)z L{renderElement} returns NOT_DONE_YET and eventually writes the rendered L{Element} to the request before finishing the request. _rD���Nc���������������������j������������������dj������������������j������������������j������������������������d�������j ������������������j������������������j �������������������������y�)Nr0���s$���<!DOCTYPE html> <p>Hello, world.</p>)r)���joinrq���writtenr?��finishedrc��r,���s��� r.���checkz3RenderElementTests.test_simpleRender.<locals>.check��sB����   --.< � OODLL11 2r0���)rI��rq��� notifyFinishrO�� addCallbackrN���r���r���r,���rO���dri��s���` r.���test_simpleRenderz$RenderElementTests.test_simpleRender��s_���� �- LL % % ' 3V� 3� 3� e \=w+OPr0���c����������������������t���������������}�j������������������j�������������������������}dt��������ddf�fd }|j ������������������|��������j ������������������t ��������t���������j������������������|�������������|S�)z L{renderElement} handles failures by writing a minimal error message to the request and finishing it. rc��rD���Nc��������������������j������������������t��������������}j������������������t��������|������d�������j������������������dj ������������������j ������������������j ������������������������d�������j������������������j ������������������j�������������������������y�)Nr���r0���s���<!DOCTYPE html> <div style="font-size:800%;background-color:#FFF;color:#F00">An error occurred while rendering the response.</div>) flushLoggedErrorsr���r)���r���re��rq���rf��r?��rg��)rc��flushedr,���s��� r.���ri��z4RenderElementTests.test_simpleFailure.<locals>.check1��si����,,^<G   S\1 -   --.O � OODLL11 2r0���)rQ��rq���rj��rO��rk��rN���r���r���rl��s���` r.���test_simpleFailurez%RenderElementTests.test_simpleFailure(��s`���� �!" LL % % ' 3V� 3� 3� e \=w+OPr0���c�����������������4����t��������j�������������������t��������������d�j������������������j������������������_��������t ���������������}�j������������������j�������������������������}dt��������ddf�fd }|j������������������|�������t���������j������������������|t���������������|S�)z L{renderElement} will render a traceback when rendering of the element fails and our site is configured to display tracebacks. Trc��rD���Nc��������������������j������������������dt���������������������d���d���}j������������������|j������������������t���������������j ������������������t��������������}j ������������������t��������|������d�������j ������������������dj������������������j������������������j������������������������d�������j������������������j������������������j�������������������������y�)Nr���r��� log_failurer0���s ���<!DOCTYPE html> <p>I failed.</p>) assertEqualsr���rB��valuer���rq��r)���re��rq���rf��r?��rg��)rc��frr�� logObserverr,���s��� r.���ri��zARenderElementTests.test_simpleFailureWithTraceback.<locals>.checkR��s����   a[!1 2A}-A  ! !!''> :,,^<G   S\1 -   --.0T � OODLL11 2r0���) _failElement) r ���createWithCleanupr ���rq���r\��rW��rQ��rj��rO��rk��r���rK��)r,���rO���rm��ri��rz��s���` @r.���test_simpleFailureWithTracebackz2RenderElementTests.test_simpleFailureWithTracebackF��s{���� �+<<TCUV .2 + " LL % % ' 3V� 3� 3� edllG:LMr0���c����������������������t���������������}�j������������������j�������������������������}dt��������ddf�fd }|j ������������������|�������t ���������j������������������|d�������|S�)zs L{renderElement} will write the doctype string specified by the doctype keyword argument. rc��rD���Nc�����������������p����j������������������dj������������������j������������������j������������������������d�������y�)Nr0���s���<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <p>Hello, world.</p>r)���re��rq���rf��rh��s��� r.���ri��z8RenderElementTests.test_nonDefaultDoctype.<locals>.checkl��s,����   --., r0���sm���<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">doctyperI��rq���rj��rO��rk��r���rl��s���` r.���test_nonDefaultDoctypez)RenderElementTests.test_nonDefaultDoctypec��s^���� �- LL % % ' V� � � e LL I  �r0���c����������������������t���������������}�j������������������j�������������������������}dt��������ddf�fd }|j ������������������|�������t ���������j������������������|d�������|S�)zs L{renderElement} will not write out a doctype if the doctype keyword argument is L{None}. rc��rD���Nc�����������������p����j������������������dj������������������j������������������j������������������������d�������y�)Nr0���r���r��rh��s��� r.���ri��z2RenderElementTests.test_noneDoctype.<locals>.check��s'����   SXXdll&:&:;=T Ur0���r��r��rl��s���` r.���test_noneDoctypez#RenderElementTests.test_noneDoctype��sW���� �- LL % % ' VV� V� V� edllGT:r0���rC���) rE���rF���rG���rH���r=��r���rn��rs��r}��r��r��rI���r0���r.���r`��r`����s]����, 8D>�.HTN�<$�:�@(4.�r0���r`��)FrH���r���ior���typingr���r���zope.interfacer���zope.interface.verifyr���twisted.internet.deferr���r ���twisted.internet.testingr ���twisted.loggerr ���twisted.python.failurer ���twisted.python.filepathr ���twisted.trial.unittestr���twisted.trial.utilr���SUPPRESStwisted.web._elementr���twisted.web.errorr���r���r���twisted.web.iwebr���r���twisted.web.serverr���twisted.web.templater���r���r���r���r���r���r���r���r���twisted.web.test._utilr ���twisted.web.test.test_webr!���r���r���r&���rK���r���r���r���r���r���r���r���r:��rI��rK��rQ��rV��rY��r`��rI���r0���r.���<module>r�����sS��� ��!�&�.�4�9�-�*�,�+�3�5�X�X�6�+ � � �3�2  ?�)@h�)@XeT8�eTP,x�,>21�21j .8%8� .x)<�" 68%8� 6 x)<� "S:o�S:l :_�:: '�  �  W��� X � � M�Mr0���