Ϫf:dZddlmZddlmZddlmZGddZdZ Gdd Z Gd d Z Gd d Z GddZ y)a I{Private} test utilities for use throughout Twisted's test suite. Unlike C{proto_helpers}, this is no exception to the don't-use-it-outside-Twisted-we-won't-maintain-compatibility rule! @note: Maintainers be aware: things in this module should be gradually promoted to more full-featured test helpers and exposed as public API as your maintenance time permits. In order to be public API though, they need their own test cases. )BytesIO)minidom) FileWrapperc"eZdZdZdZdZdZy)IOPumpzUtility to pump data between clients and servers for protocol testing. Perhaps this is a utility worthy of being in protocol.py? c<||_||_||_||_y)N)clientserverclientIOserverIO)selfr r r r s 8/usr/lib/python3/dist-packages/twisted/test/testutils.py__init__zIOPump.__init__s      cJ|jr |jryy)z,Pump until there is no more input or output.N)pump)r s rflushz IOPump.flush!siik iikrc>|jjd|jjd|jj}|jj}|jjd|jjd|jj |jj |D]}|j j ||D]}|jj ||s|ryy)zOMove data back and forth. Returns whether any data was moved. r)r seekr readtruncater dataReceivedr )r cDatasDatabytes rrz IOPump.pump&s 1 1 ""$ ""$ 1 1     +D KK $ $T * + +D KK $ $T * + ErN)__name__ __module__ __qualname____doc__rrrrrrrs !  rrct}t}|jt||jt|t||||}|j |j |S)z-Take two Protocol instances and connect them.)rmakeConnectionrrr)r r ciosiors rreturnConnectedr&=s] )C )C +c*+ +c*+ &&#s +DJJLJJL KrceZdZdZdZy)XMLAssertionMixinz Test mixin defining a method for comparing serialized XML documents. Must be mixed in to a L{test case}. c|jtj|jtj|jy)z Verify that two strings represent the same XML document. @param first: An XML string. @type first: L{bytes} @param second: An XML string that should match C{first}. @type second: L{bytes} N) assertEqualdom parseStringtoxml)r firstseconds rassertXMLEqualz XMLAssertionMixin.assertXMLEqualRs;  OOE " ( ( *COOF,C,I,I,K rN)rrrr r0r!rrr(r(Ks   rr(c eZdZdZdedefdZy)_EqualzN A class the instances of which are equal to anything and everything. otherreturncy)NTr!r r3s r__eq__z _Equal.__eq__fsrNrrrr objectboolr7r!rrr2r2asFtrr2c eZdZdZdedefdZy) _NotEqualz> A class the instances of which are equal to nothing. r3r4cy)NFr!r6s rr7z_NotEqual.__eq__osrNr8r!rrr<r<jsFtrr<ceZdZdZdZy)ComparisonTestsMixina A mixin which defines a method for making assertions about the correctness of an implementation of C{==} and C{!=}. Use this to unit test objects which follow the common convention for C{==} and C{!=}: - The object compares equal to itself - The object cooperates with unrecognized types to allow them to implement the comparison - The object implements not-equal as the opposite of equal c|j||k(|j||k(|j||k(|j||k7|j||k7|j||k7|j|tk(|j|tk7|j|tk(|j|tk7y)aU Assert that C{firstValueOne} is equal to C{secondValueOne} but not equal to C{valueOne} and that it defines equality cooperatively with other types it doesn't know about. @param firstValueOne: An object which is expected to compare as equal to C{secondValueOne} and not equal to C{valueTwo}. @param secondValueOne: A different object than C{firstValueOne} but which is expected to compare equal to that object. @param valueTwo: An object which is expected to compare as not equal to C{firstValueOne}. N) assertTrue assertFalser2r<)r firstValueOnesecondValueOnevalueTwos r"assertNormalEqualityImplementationz7ComparisonTestsMixin.assertNormalEqualityImplementations.  67  78 (23 -78 .89  12  12 &(23 )+56  45rN)rrrr rFr!rrr?r?ss   6rr?N)r iorxml.domrr+twisted.internet.protocolrrr&r(r2r<r?r!rrrJsM "1%%P   ,.6.6r