o
¯b: ã @ sz d Z ddlmZ ddlmZ ddlmZ G dd„ dƒZdd„ Z G d d
„ d
ƒZ
G dd„ dƒZG d
d„ dƒZG dd„ dƒZ
dS )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 @ s( e Zd ZdZdd„ Zdd„ Zdd„ ZdS ) ÚIOPumpzŠUtility to pump data between clients and servers for protocol testing.
Perhaps this is a utility worthy of being in protocol.py?
c C s || _ || _|| _|| _d S )N)ÚclientÚserverÚclientIOÚserverIO)Úselfr r r r © r ú8/usr/lib/python3/dist-packages/twisted/test/testutils.pyÚ__init__ s
zIOPump.__init__c C s | ¡ r | ¡ sdS dS )z,Pump until there is no more input or output.N)Úpump)r
r r r Úflush! s ÿzIOPump.flushc C s” | j d¡ | j d¡ | j ¡ }| j ¡ }| j d¡ | j d¡ | j ¡ | j ¡ |D ]}| j |¡ q.|D ]}| j |¡ q9|sF|rHdS dS )zOMove data back and forth.
Returns whether any data was moved.
r é )r Úseekr ÚreadÚtruncater ÚdataReceivedr )r
ÚcDataÚsDataÚbyter r r r &