+
    Dfj                        R t ^ RIt^ RIHtHt ^ RIHt ^ RIHtH	t	 ^ RI
Ht ^ RIHt ^ RIHt ^ RIHtHtHtHtHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt ^ RIHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't' ]#PP                  ! 4       '       g   Rt)MRt) ! R R]4      t* ! R R4      t+ ! R R4      t, ! R R]'PZ                  4      t. ! R R]'PZ                  ]4      t/ ! R R]'PZ                  4      t0 ! R R ]'PZ                  4      t1 ! R! R"]'PZ                  4      t2 ! R# R$4      t3 ! R% R&]'PZ                  4      t4 ! R' R(]'PZ                  4      t5R# ))z)
Test cases for L{twisted.names.client}.
N)verifyClassverifyObject)defer)CannotListenErrorConnectionRefusedError)	IResolver)Clock)AlternateReactor)cacheclientdnserrorhosts)ResolverBase)DNSQueryTimeoutError)	test_util)GoodTempPathMixin)failure)FilePath)platform)proto_helpers)unittestz:These tests need more work before they'll work on Windows.c                   &   a  ] tR t^#t o R tRtV tR# )FakeResolverc                    VR8X  dA   \         P                  ! V\         P                  V^<\         P                  ! R^<R7      R7      pM\         P                  ! WV^<R7      pV.p. p. p\        P
                  ! WgV34      # )z
The getHostByNameTest does a different type of query that requires it
return an A record from an ALL_RECORDS lookup, so we accommodate that
here.
   getHostByNameTest	127.0.0.1)addressttl)nametypeclsr   payload)r   r    r!   r   )r   RRHeaderARecord_Ar   succeed)	selfr   r!   qtypetimeoutrrresults	authority
additionals	   &&&&&    @/usr/lib/python3/dist-packages/twisted/names/test/test_client.py_lookupFakeResolver._lookup$   sr     ''UU[bAB 4"EB$	
}}g*=>>     N)__name__
__module____qualname____firstlineno__r/   __static_attributes____classdictcell____classdict__s   @r.   r   r   #   s     ? ?r1   r   c                   .   a  ] tR t^;t o RtRtR tRtV tR# )StubPortz
A partial implementation of L{IListeningPort} which only keeps track of
whether it has been stopped.

@ivar disconnected: A C{bool} which is C{False} until C{stopListening} is
    called, C{True} afterwards.
Fc                    R V n         R# )TNdisconnectedr'   s   &r.   stopListeningStubPort.stopListeningF   s
     r1   r>   N)	r3   r4   r5   r6   __doc__r?   rA   r7   r8   r9   s   @r.   r<   r<   ;   s      L! !r1   r<   c                   4   a  ] tR t^Jt o RtR tRR ltRtV tR# )StubDNSDatagramProtocolz
L{dns.DNSDatagramProtocol}-alike.

@ivar queries: A C{list} of tuples giving the arguments passed to
    C{query} along with the L{defer.Deferred} which was returned from
    the call.
c                2    . V n         \        4       V n        R # Nqueriesr<   	transportr@   s   &r.   __init__ StubDNSDatagramProtocol.__init__S       !r1   Nc                l    \         P                  ! 4       pV P                  P                  WW4V34       V# )z^
Record the given arguments and return a Deferred which will not be
called back by this code.
)r   DeferredrI   append)r'   r   rI   r)   idresults   &&&&& r.   queryStubDNSDatagramProtocol.queryW   s.    
 !WwFCDr1   rI   rJ   
   N)	r3   r4   r5   r6   rC   rK   rS   r7   r8   r9   s   @r.   rE   rE   J   s     $ r1   rE   c                   4   a  ] tR t^at o Rt]tR tR tRt	V t
R# )GetResolverTestsz"
Tests for L{client.getResolver}.
c                    \        \        4       4      ;_uu_ 4        \        P                  ! 4       pRRR4       V P	                  \        \        X4      4       R#   + '       g   i     L1; i)zA
L{client.getResolver} returns an object providing L{IResolver}.
N)r	   r   r   getResolver
assertTruer   r   r'   resolvers   & r.   test_interfaceGetResolverTests.test_interfaceh   s@     eg&&))+H 'Y9: '&s   AA+	c                    \        \        4       4      ;_uu_ 4        \        P                  ! 4       p\        P                  ! 4       pRRR4       V P	                  XX4       R#   + '       g   i     L$; i)zV
Multiple calls to L{client.getResolver} return the same L{IResolver}
implementation.
N)r	   r   r   r[   assertIs)r'   abs   &  r.   test_idempotent GetResolverTests.test_idempotentp   sK    
 eg&&""$A""$A ' 	a '&s   +A##A3	r2   N)r3   r4   r5   r6   rC   windowsSkipskipr_   re   r7   r8   r9   s   @r.   rY   rY   a   s       D; r1   rY   c                   d   a  ] tR t^{t o Rt]tR tR tR t	R t
R tR tR tR	 tR
 tR tRtV tR# )CreateResolverTestsz%
Tests for L{client.createResolver}.
c                   VP                    Uu. uF'  p\        V\        P                  4      '       g   K%  VNK)  	  ppV P	                  ^\        V4      4       V P	                  V^ ,          P                  V4       R# u upi    N)	resolvers
isinstancer   ResolverassertEquallenfiler'   r^   filenamerress   &&&  r.   
_hostsTestCreateResolverTests._hostsTest   s_    ",,N,Q
1enn0Mqq,NCH%Qh/ O
   "A>A>c                    \        \        4       4      ;_uu_ 4        \        P                  ! 4       pRRR4       V P	                  XR4       R#   + '       g   i     L$; i)z
L{client.createResolver} returns a L{resolve.ResolverChain} including a
L{hosts.Resolver} using I{/etc/hosts} if no alternate hosts file is
specified.
Ns
   /etc/hostsr	   r   r   createResolverrx   r]   s   & r.   test_defaultHosts%CreateResolverTests.test_defaultHosts   s;     eg&&,,.H '-0 '&   AA	c                    \        \        4       4      ;_uu_ 4        \        P                  ! RR7      pRRR4       V P	                  XR4       R#   + '       g   i     L$; i)z
The I{hosts} parameter to L{client.createResolver} overrides the hosts
file used by the L{hosts.Resolver} in the L{resolve.ResolverChain} it
returns.
   /foo/bar)r   Nr|   r]   s   & r.   test_overrideHosts&CreateResolverTests.test_overrideHosts   s=     eg&&,,;?H '+. '&   AA 	c                   VP                    Uu. uF'  p\        V\        P                  4      '       g   K%  VNK)  	  ppV P	                  ^\        V4      4       V P	                  V^ ,          P                  V4       R# u upi )zd
Verify that C{resolver} has a L{client.Resolver} with a configuration
filename set to C{filename}.
N)rn   ro   r   rp   rq   rr   resolvrt   s   &&&  r.   _resolvConfTest#CreateResolverTests._resolvConfTest   sa    
 #,,O,Q
1foo0Nqq,OCH%Q1 Prz   c                   \        4       p\        V4      ;_uu_ 4        \        P                  ! 4       pRRR4       XP                   Uu. uF'  p\        V\        P                  4      '       g   K%  VNK)  	  ppV P                  ^\        V4      4       V P                  W^ ,          P                  4       R#   + '       g   i     L; iu upi )z
The L{client.Resolver} included in the L{resolve.ResolverChain} returned
by L{client.createResolver} uses the global reactor.
N)r   r	   r   r}   rn   ro   rp   rq   rr   rb   _reactor)r'   reactorr^   rv   rw   s   &    r.   test_reactor CreateResolverTests.test_reactor   s    
 'g&&,,.H '",,O,Q
1foo0Nqq,OCH%g1v/	 '&Os   B8
"C1C8C	c                    \        \        4       4      ;_uu_ 4        \        P                  ! 4       pRRR4       V P	                  XR4       R#   + '       g   i     L$; i)z
L{client.createResolver} returns a L{resolve.ResolverChain} including a
L{client.Resolver} using I{/etc/resolv.conf} if no alternate resolver
configuration file is specified.
Ns   /etc/resolv.confr	   r   r   r}   r   r]   s   & r.   test_defaultResolvConf*CreateResolverTests.test_defaultResolvConf   s>     eg&&,,.H 'X':; '&r   c                    \        \        4       4      ;_uu_ 4        \        P                  ! RR7      pRRR4       V P	                  XR4       R#   + '       g   i     L$; i)z
The I{resolvconf} parameter to L{client.createResolver} overrides the
resolver configuration file used by the L{client.Resolver} in the
L{resolve.ResolverChain} it returns.
r   
resolvconfNr   r]   s   & r.   test_overrideResolvConf+CreateResolverTests.test_overrideResolvConf   s?     eg&&,,DH 'X{3 '&r   c                @   V P                  4       pVP                  R4       \        \        4       4      ;_uu_ 4        \        P
                  ! VP                   R7      pRRR4       XP                   Uu. uF'  p\        V\        P                  4      '       g   K%  VNK)  	  ppV P                  ^\        V4      4       V P                  . V^ ,          P                  4       V P                  R.V^ ,          P                  4       R#   + '       g   i     L; iu upi )z~
If no servers are given, addresses are taken from the file given by the
I{resolvconf} parameter to L{client.createResolver}.
   nameserver 127.1.2.3
r   Nz	127.1.2.35   path
setContentr	   r   r   r}   rn   ro   rp   rq   rr   servers
dynServersr'   r   r^   rv   rw   s   &    r.   test_defaultServers'CreateResolverTests.test_defaultServers   s    
 YY[
78eg&&,,
HH '",,O,Q
1foo0Nqq,OCH%SV^^,+,c!f.?.?@ '&Os   "D5"DDD	c                F   V P                  4       pVP                  R4       \        \        4       4      ;_uu_ 4        \        P
                  ! R.VP                   R7      pRRR4       XP                   Uu. uF'  p\        V\        P                  4      '       g   K%  VNK)  	  ppV P                  ^\        V4      4       V P                  R.V^ ,          P                  4       V P                  R.V^ ,          P                  4       R#   + '       g   i     L; iu upi )z
Servers passed to L{client.createResolver} are used in addition to any
found in the file given by the I{resolvconf} parameter.
r   )r   r   N)z	127.3.2.1r   r   r   r   s   &    r.   test_overrideServers(CreateResolverTests.test_overrideServers   s    
 YY[
78eg&&,,*+
H ' #,,O,Q
1foo0Nqq,OCH%+,c!fnn=+,c!f.?.?@ '& Ps   $D7"DDD	c                X   \        \        4       4      ;_uu_ 4        \        P                  ! 4       pRRR4       XP                   Uu. uF'  p\        V\        P                  4      '       g   K%  VNK)  	  ppV P                  ^\        V4      4       R#   + '       g   i     Lj; iu upi )za
L{client.createResolver} returns a L{resolve.ResolverChain} including a
L{cache.CacheResolver}.
N)
r	   r   r   r}   rn   ro   r
   CacheResolverrq   rr   )r'   r^   rv   rw   s   &   r.   
test_cacheCreateResolverTests.test_cache   sp    
 eg&&,,.H '",,S,Q
1e>Q>Q0Rqq,SCH% '&Ss   B"B'/B'B$	r2   N)r3   r4   r5   r6   rC   rg   rh   rx   r~   r   r   r   r   r   r   r   r   r7   r8   r9   s   @r.   rj   rj   {   sJ      D0
1/2
0<4AA & &r1   rj   c                      a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t Rt!V t"R# ) ResolverTestsz
Tests for L{client.Resolver}.
c                .    \        \        \        4       R# )zE
L{client} provides L{IResolver} through a series of free
functions.
N)r   r   r   r@   s   &r.   test_clientProvidesIResolver*ResolverTests.test_clientProvidesIResolver   s    
 	Y'r1   c                B    \        \        \        P                  4       R# )z+
L{client.Resolver} provides L{IResolver}.
N)r   r   r   rp   r@   s   &r.   $test_clientResolverProvidesIResolver2ResolverTests.test_clientResolverProvidesIResolver   s     	Iv/r1   c                N    V P                  \        \        P                  4       R# )zr
L{client.Resolver} raises L{ValueError} if constructed with neither
servers nor a nameserver configuration file.
N)assertRaises
ValueErrorr   rp   r@   s   &r.   test_noServersResolverTests.test_noServers   s    
 	*foo6r1   c                    \         P                  ! V P                  4       \        4       R7      pV P	                  R.VP
                  4       R# )z
A missing nameserver configuration file results in no server information
being loaded from it (ie, not an exception) and a default server being
provided.
r   r   Nr   r   )r   rp   mktempr   rq   r   r]   s   & r.   test_missingConfiguration'ResolverTests.test_missingConfiguration  s6     ??$++-I+,h.A.ABr1   c                   a \        V P                  4       4      pVP                  RR7      o ! V3R lR\        P                  4      pV! R^5.R\        4       R7       V P                  SP                  4       R# )	z
As part of its constructor, C{StubResolver} opens C{/etc/resolv.conf};
then, explicitly closes it and does not count on the GC to do so for
it.
zw+)modec                   .   <a  ] tR tRt o V3R ltRtV tR# )9ResolverTests.test_closesResolvConf.<locals>.StubResolveri  c                   < S# rG   r2   )r'   r   
resolvConfs   &&r.   	_openFileCResolverTests.test_closesResolvConf.<locals>.StubResolver._openFile  s	    !!r1   r2   N)r3   r4   r5   r6   r   r7   r8   )r:   r   s   @r.   StubResolverr     s     " "r1   r   example.comz/etc/resolv.conf)r   r   r   N)r   r   openr   rp   r   r\   closed)r'   handler   r   s   &  @r.   test_closesResolvConf#ResolverTests.test_closesResolvConf  sb     $++-([[d[+
	"6?? 	" 	"B'0BEG	
 	
))*r1   c                    \         P                  ! R.R7      pVP                  R.4       V P                  RVP                  4       R# )zn
L{client.Resolver.parseConfig} treats a I{domain} line without an
argument as indicating a domain of C{b""}.
r   s   domain
r1   Nr   )r   rp   parseConfigrq   domainr]   s   & r.   test_domainEmptyArgument&ResolverTests.test_domainEmptyArgument!  s:    
 ??,=+>?k]+hoo.r1   c                    \         P                  ! R.R7      pVP                  R.4       V P                  . VP                  4       R# )zr
L{client.Resolver.parseConfig} treats a I{search} line without an
argument as indicating an empty search suffix.
r   s   search
Nr   )r   rp   r   rq   searchr]   s   & r.   test_searchEmptyArgument&ResolverTests.test_searchEmptyArgument*  s:    
 ??,=+>?k]+X__-r1   c                  a \        4       oRR.pRR.p\        P                  ! VR7      pW#n        V3R lVn        \        4       pVP                  R4      pVP                  V P                  V4       V P                  \        SP                  4      ^4       V P                  SP                  ^ ,          ^ ,          V^ ,          4       SP                  ^ ,          R,          P                  \        ^ 4      4       V P                  \        SP                  4      ^4       V P                  SP                  ^,          ^ ,          V^,          4       SP                  ^,          R,          P                  \        ^4      4       V P                  \        SP                  4      ^4       V P                  SP                  ^,          ^ ,          V^ ,          4       SP                  ^,          R,          P                  \        ^4      4       V P                  \        SP                  4      ^4       V P                  SP                  ^,          ^ ,          V^,          4       SP                  ^,          R,          P                  V4       V# )	z
L{client.Resolver.queryUDP} should issue queries to its
L{dns.DNSDatagramProtocol} with server addresses taken from its own
C{servers} and C{dynServers} lists, proceeding through them in order
as L{DNSQueryTimeoutError}s occur.
r   c                    < S# rG   r2   )	interfaceprotocols   &r.   <lambda>=ResolverTests.test_datagramQueryServerOrder.<locals>.<lambda>@  s    r1   Nz::1r   )z::2r   )z::3r   )z::4r   )rE   r   rp   r   _connectedProtocolobjectqueryUDPaddCallbackrq   rr   rI   rb   errbackr   callback)r'   r   r   r^   expectedResultqueryResultr   s   &     @r.   test_datagramQueryServerOrder+ResolverTests.test_datagramQueryServerOrder3  s    +,,!;/
??73(&@#''- 0 0.AX--.2h&&q)!,gaj9B''(<Q(?@X--.2h&&q)!,gaj9B''(<Q(?@X--.2h&&q)!,jm<B''(<Q(?@X--.2h&&q)!,jm<B((8r1   c                  a a	a
 \        4       o
\        P                  ! R.R7      pV
3R lVn        S
P                  p\
        P                  ! R\
        P                  \
        P                  4      pVP                  V4      pS P                  \        V4      ^4       VP                  V4      pS P                  \        V4      ^4       \        4       o	\
        P                  ! 4       pVP                  P                  S	4       VP!                  4       R,          P#                  V4       \$        P&                  ! WE.4      pV	V 3R lpVP)                  V4       V# )z
L{client.Resolver.query} only issues one request at a time per query.
Subsequent requests made before responses to prior ones are received
are queued and given the same response as is given to the first one.
r   c                     < S # rG   r2   r   s   r.   r   <ResolverTests.test_singleConcurrentRequest.<locals>.<lambda>]      hr1      foo.example.comc                 h   < V w  rSP                  VS.. . 34       SP                  VS.. . 34       R # rG   rq   )	responsesfirstResponsesecondResponseanswerr'   s   &  r.   
cbFinished>ResolverTests.test_singleConcurrentRequest.<locals>.cbFinishedr  s=    ,5)M]fXr2,>?^vhB-?@r1   r   r   r   )rE   r   rp   r   rI   r   Queryr$   INrS   rq   rr   r   MessageanswersrP   popr   r   gatherResultsr   )r'   r^   rI   rS   firstResultsecondResultresponsedr   r   r   s   f        @@r.   test_singleConcurrentRequest*ResolverTests.test_singleConcurrentRequestU  s     +,??,?+@A&6#""		,ceeSVV<nnU+Wq)  ~~e,Wq) ;;='b""8, ;<	A
 	
j!r1   c                `  a \        4       o\        P                  ! R.R7      pV3R lVn        SP                  p\
        P                  ! R\
        P                  4      pVP                  V4       V P                  \        V4      ^4       \
        P                  ! R\
        P                  4      pVP                  V4       V P                  \        V4      ^4       \
        P                  ! R\
        P                  4      pVP                  V4       V P                  \        V4      ^4       R# )zP
L{client.Resolver.query} issues a request for each different concurrent
query.
r   c                     < S # rG   r2   r   s   r.   r   ?ResolverTests.test_multipleConcurrentRequests.<locals>.<lambda>  r   r1   r      bar.example.comNr   )rE   r   rp   r   rI   r   r   r$   rS   rq   rr   A6)r'   r^   rI   
firstQuerysecondQuery
thirdQueryr   s   &     @r.   test_multipleConcurrentRequests-ResolverTests.test_multipleConcurrentRequestsz  s    
 +,??,?+@A&6#"" YY13559
z"Wq) ii 2CEE:{#Wq) YY1366:
z"Wq)r1   c                  a \        4       o\        P                  ! R.R7      pV3R lVn        SP                  p\
        P                  ! R\
        P                  4      pVP                  V4       V P                  \        V4      ^4       VP                  4       R,          P                  \
        P                  ! 4       4       VP                  V4       V P                  \        V4      ^4       R# )z
After a response is received to a query issued with
L{client.Resolver.query}, another query with the same parameters
results in a new network request.
r   c                     < S # rG   r2   r   s   r.   r   ?ResolverTests.test_multipleSequentialRequests.<locals>.<lambda>  r   r1   r   Nr   r   )rE   r   rp   r   rI   r   r   r$   rS   rq   rr   r   r   r   )r'   r^   rI   rS   r   s   &   @r.   test_multipleSequentialRequests-ResolverTests.test_multipleSequentialRequests  s     +,??,?+@A&6#""		,cee4 	uWq) 	b""3;;=1 	uWq)r1   c                  a \        4       o\        P                  ! R.R7      pV3R lVn        SP                  p\
        P                  ! R\
        P                  4      pVP                  V4      pVP                  V4      p ! R R\        4      pVP                  4       R,          P                  \        P                  ! V! 4       4      4       \        P                  ! V P!                  WF4      V P!                  WV4      .4      # )z
If the result of a request is an error response, the Deferreds for all
concurrently issued requests associated with that result fire with the
L{Failure}.
r   c                     < S # rG   r2   r   s   r.   r   >ResolverTests.test_multipleConcurrentFailure.<locals>.<lambda>  r   r1   r   c                       ] tR tRtRtR# )GResolverTests.test_multipleConcurrentFailure.<locals>.ExpectedExceptioni  r2   Nr3   r4   r5   r6   r7   r2   r1   r.   ExpectedExceptionr        r1   r  r   r   )rE   r   rp   r   rI   r   r   r$   rS   	Exceptionr   r   r   Failurer   r   assertFailure)r'   r^   rI   rS   r   r   r  r   s   &      @r.   test_multipleConcurrentFailure,ResolverTests.test_multipleConcurrentFailure  s     +,??,?+@A&6#""		,cee4nnU+~~e,		 	 	b!!'//2C2E"FG"""";B""<C
 	
r1   c                Z   \         P                  ! R.R7      pVP                  4       pVP                  4       pV P                  VP                  4       V P                  VP                  4       V P                  VP                  P                  4       P                  VP                  P                  4       P                  4       \        P                  ! \        P                  ! VP                  P                  4      \        P                  ! VP                  P                  4      .4      # )z
L{client.Resolver._connectedProtocol} returns a new
L{DNSDatagramProtocol} connected to a new address with a
cryptographically secure random port number.
r   r   )r   rp   r   assertIsNotNonerJ   assertNotEqualgetHostportr   r   maybeDeferredrA   )r'   r^   
firstProtosecondProtos   &   r.   test_connectedProtocol$ResolverTests.test_connectedProtocol  s     ??,?+@A002
113Z112[223  ((*//1F1F1N1N1P1U1U	
 ""##J$8$8$F$FG##K$9$9$G$GH
 	
r1   c                    \         P                  ! 4       p\        P                  ! V P	                  4       VR7      pVP                  4       pV P                  VP                  V4       R# )z
If a reactor instance is supplied to L{client.Resolver}
L{client.Resolver._connectedProtocol} should pass that reactor
to L{twisted.names.dns.DNSDatagramProtocol}.
r   N)r   MemoryReactorr   rp   r   r   rb   r   )r'   r   r^   protos   &   r.   )test_resolverUsesOnlyParameterizedReactor7ResolverTests.test_resolverUsesOnlyParameterizedReactor  sH     ))+??$++-I++-enng.r1   c                >  a \         P                  ! R.R7      p. o ! V3R lR4      pW!n        VP                  \        P
                  ! R4      4       VP                  \        P
                  ! R4      4       V P                  \        \        S4      4      ^4       R# )z
L{client.Resolver._connectedProtocol} is called once each time a UDP
request needs to be issued and the resulting protocol instance is used
for that request.
r   c                   8   <a  ] tR tRt o R tRV3R lltRtV tR# ):ResolverTests.test_differentProtocol.<locals>.FakeProtocoli  c                $    \        4       V n        R # rG   r<   rJ   r@   s   &r.   rK   CResolverTests.test_differentProtocol.<locals>.FakeProtocol.__init__      !)r1   Nc                x   < SP                  V 4       \        P                  ! \        P                  ! 4       4      # rG   )rP   r   r&   r   r   )r'   r   rS   r)   rQ   	protocolss   &&&&&r.   rS   @ResolverTests.test_differentProtocol.<locals>.FakeProtocol.query  s&      &}}S[[]33r1   rJ   rV   r3   r4   r5   r6   rK   rS   r7   r8   )r:   r7  s   @r.   FakeProtocolr1    s     ,4 4r1   r;  r   r  Nr   )	r   rp   r   rS   r   r   rq   rr   set)r'   r^   r;  r7  s   &  @r.   test_differentProtocol$ResolverTests.test_differentProtocol  ss     ??,?+@A		4 	4 '3#syy!345syy!345S^,a0r1   c                @   \         P                  ! 4       p\        P                  ! R.VR7      pVP	                  \
        P                  ! R4      4       VP                  P                  4       w  w  r4VP                  4       P                  pV P                  RV4       R# )z,
If the resolver is ipv6, open a ipv6 port.
r   r   r   z::Nr   )r   r+  r   rp   rS   r   r   udpPortsitemsr#  hostrq   )r'   faker^   r,  rJ   r   s   &     r.   test_ipv6ResolverResolverTests.test_ipv6Resolver   sv    
 &&(??K=$Gsyy!345#}}224	%%%',,	y)r1   c                   a . o ! V3R lR4      p\         P                  ! R.R7      pV! 4       Vn        VP                  4        V P	                  \        \        S4      4      ^4       R# )z
If a port number is initially selected which cannot be bound, the
L{CannotListenError} is handled and another port number is attempted.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )6ResolverTests.test_disallowedPort.<locals>.FakeReactori  c                d   < SP                  V4       \        S4      ^8X  d   \        RVR4      hR# rl   )rP   rr   r   r'   r$  argskwargsportss   &&*,r.   	listenUDP@ResolverTests.test_disallowedPort.<locals>.FakeReactor.listenUDP  s.    T"u:?+D$== #r1   r2   Nr3   r4   r5   r6   rO  r7   r8   r:   rN  s   @r.   FakeReactorrI    s     > >r1   rS  r   Nr   )r   rp   r   r   rq   rr   r<  r'   rS  r^   rN  s   &  @r.   test_disallowedPort!ResolverTests.test_disallowedPort  sV    
 	> 	> ??,?+@A'M##%SZ!,r1   c                   a . o ! V3R lR4      p\         P                  ! R.R7      pV! 4       Vn        V P                  \        VP
                  4       V P                  \        S4      R4       R# )zw
If port numbers that cannot be bound are repeatedly selected,
L{resolver._connectedProtocol} will give up eventually.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )@ResolverTests.test_disallowedPortRepeatedly.<locals>.FakeReactori&  c                @   < SP                  V4       \        R VR 4      hrG   )rP   r   rK  s   &&*,r.   rO  JResolverTests.test_disallowedPortRepeatedly.<locals>.FakeReactor.listenUDP'  s    T"'dD99r1   r2   NrQ  rR  s   @r.   rS  rY  &  s     : :r1   rS  r   i  Nr   )r   rp   r   r   r   r   rq   rr   rT  s   &  @r.   test_disallowedPortRepeatedly+ResolverTests.test_disallowedPortRepeatedly  s]    
 	: 	:
 ??,?+@A'M+X-H-HIUT*r1   c                L  a . o ! V3R lR4      p\         P                  ! R.R7      pV! 4       Vn        V P                  \        VP
                  4      pV P                  VP                  P                  \        P                  4       V P                  \        S4      ^4       R# )zN
If the process is out of files, L{Resolver._connectedProtocol}
will give up.
c                   .   <a  ] tR tRt o V3R ltRtV tR# )5ResolverTests.test_runOutOfFiles.<locals>.FakeReactori9  c                r   < SP                  V4       \        \        P                  R 4      p\	        RW4      h)zOut of files :(N)rP   OSErrorerrnoEMFILEr   )r'   r$  rL  rM  errrN  s   &&*, r.   rO  ?ResolverTests.test_runOutOfFiles.<locals>.FakeReactor.listenUDP:  s-    T"ell,=>'d88r1   r2   NrQ  rR  s   @r.   rS  r`  9  s     9 9r1   rS  r   Nr   )r   rp   r   r   r   r   rq   socketErrorrc  rd  rr   )r'   rS  r^   excrN  s   &   @r.   test_runOutOfFiles ResolverTests.test_runOutOfFiles2  s    
 	9 	9 ??,?+@A'M 183N3NO 	..=UQ'r1   c                  aa \         P                  ! R.R7      p. o\        P                  ! \        P
                  ! \        R4      4      4      \        P                  ! \        P                  ! 4       4      .o ! VV3R lR4      pW!n
        VP                  \        P                  ! R4      4       V P                  \        \        S4      4      ^4       R# )zd
When a query issued by L{client.Resolver.query} times out, the retry
uses a new protocol instance.
r   Nc                   :   <a  ] tR tRt o R tRVV3R lltRtV tR# )FResolverTests.test_differentProtocolAfterTimeout.<locals>.FakeProtocoliT  c                $    \        4       V n        R # rG   r3  r@   s   &r.   rK   OResolverTests.test_differentProtocolAfterTimeout.<locals>.FakeProtocol.__init__U  r5  r1   Nc                H   < SP                  V 4       SP                  ^ 4      #     rP   r   r'   r   rS   r)   rQ   r7  r+   s   &&&&&r.   rS   LResolverTests.test_differentProtocolAfterTimeout.<locals>.FakeProtocol.queryX        &{{1~%r1   r9  rV   r:  r:   r7  r+   s   @r.   r;  rm  T       ,& &r1   r;  r   r   )r   rp   r   failr   r  r   r&   r   r   r   rS   r   rq   rr   r<  )r'   r^   r;  r7  r+   s   &  @@r.   "test_differentProtocolAfterTimeout0ResolverTests.test_differentProtocolAfterTimeoutH  s    
 ??,?+@A	JJw';D'ABCMM#++-(

	& 	& '3#syy!345S^,a0r1   c                  aa \         P                  ! R.R7      p. o\        P                  ! 4       o ! VV3R lR4      pW!n        VP                  \        P                  ! R4      4       V P                  S^ ,          P                  P                  4       SP                  \        P                  ! 4       4       V P                  S^ ,          P                  P                  4       R# )z
After the L{Deferred} returned by L{DNSDatagramProtocol.query} is
called back, the L{DNSDatagramProtocol} is disconnected from its
transport.
r   c                   :   <a  ] tR tRt o R tRVV3R lltRtV tR# )9ResolverTests.test_protocolShutDown.<locals>.FakeProtocolij  c                $    \        4       V n        R # rG   r3  r@   s   &r.   rK   BResolverTests.test_protocolShutDown.<locals>.FakeProtocol.__init__k  r5  r1   Nc                *   < SP                  V 4       S# rG   rP   r'   r   rS   r)   rQ   r7  rR   s   &&&&&r.   rS   ?ResolverTests.test_protocolShutDown.<locals>.FakeProtocol.queryn        &r1   r9  rV   r:  r:   r7  rR   s   @r.   r;  r~  j       , r1   r;  r   Nr   )r   rp   r   rO   r   rS   r   r   assertFalserJ   r?   r   r   r\   )r'   r^   r;  r7  rR   s   &  @@r.   test_protocolShutDown#ResolverTests.test_protocolShutDown`  s     ??,?+@A	!	 	 '3#syy!3451//<<=&	!..;;<r1   c                <  aa \         P                  ! R.R7      p. o\        P                  ! 4       p\        P                  ! \
        P                  ! \        R4      4      4      V.o ! VV3R lR4      pW1n        VP                  \        P                  ! R4      4       V P                  S^,          P                  P                  4       VP                  \        P                   ! 4       4       V P#                  S^,          P                  P                  4       R# )z
The L{DNSDatagramProtocol} created when an interim timeout occurs is
also disconnected from its transport after the Deferred returned by its
query method completes.
r   Nc                   :   <a  ] tR tRt o R tRVV3R lltRtV tR# )EResolverTests.test_protocolShutDownAfterTimeout.<locals>.FakeProtocoli  c                $    \        4       V n        R # rG   r3  r@   s   &r.   rK   NResolverTests.test_protocolShutDownAfterTimeout.<locals>.FakeProtocol.__init__  r5  r1   Nc                H   < SP                  V 4       SP                  ^ 4      # rq  rs  rt  s   &&&&&r.   rS   KResolverTests.test_protocolShutDownAfterTimeout.<locals>.FakeProtocol.query  rv  r1   r9  rV   r:  rw  s   @r.   r;  r    rx  r1   r;  r   r   )r   rp   r   rO   ry  r   r  r   r   rS   r   r   r  rJ   r?   r   r   r\   )r'   r^   rR   r;  r7  r+   s   &   @@r.   !test_protocolShutDownAfterTimeout/ResolverTests.test_protocolShutDownAfterTimeouty  s     ??,?+@A	!::goo.B4.HIJFS	& 	& '3#syy!3451//<<=&	!..;;<r1   c                  aa  ! R R\         4      p\        P                  ! R.R7      p. o\        P                  ! 4       o ! VV3R lR4      pW2n        VP                  \        P                  ! R4      4      pV P                  S^ ,          P                  P                  4       SP                  \        P                  ! V! 4       4      4       V P                  S^ ,          P                  P                  4       V P!                  WA4      # )z
If the L{Deferred} returned by L{DNSDatagramProtocol.query} fires with
a failure, the L{DNSDatagramProtocol} is still disconnected from its
transport.
c                       ] tR tRtRtR# )JResolverTests.test_protocolShutDownAfterFailure.<locals>.ExpectedExceptioni  r2   Nr  r2   r1   r.   r  r    r  r1   r  r   c                   :   <a  ] tR tRt o R tRVV3R lltRtV tR# )EResolverTests.test_protocolShutDownAfterFailure.<locals>.FakeProtocoli  c                $    \        4       V n        R # rG   r3  r@   s   &r.   rK   NResolverTests.test_protocolShutDownAfterFailure.<locals>.FakeProtocol.__init__  r5  r1   Nc                *   < SP                  V 4       S# rG   r  r  s   &&&&&r.   rS   KResolverTests.test_protocolShutDownAfterFailure.<locals>.FakeProtocol.query  r  r1   r9  rV   r:  r  s   @r.   r;  r    r  r1   r;  r   r   )r  r   rp   r   rO   r   rS   r   r   r  rJ   r?   r   r   r  r\   r  )r'   r  r^   r;  r   r7  rR   s   &    @@r.   !test_protocolShutDownAfterFailure/ResolverTests.test_protocolShutDownAfterFailure  s    		 	 ??,?+@A	!	 	 '3#nnSYY/A%BC1//<<=w'8':;<	!..;;<!!+AAr1   c                   \         P                  ! R.R7      pVP                  P                  R4      pVP	                  R4       V P                  W!P                  4       VP                  R4       V P                  W!P                  4       R# )zt
When a TCP DNS protocol associated with a Resolver disconnects, it is
removed from the Resolver's connection list.
r   Nr   )	r   rp   factorybuildProtocolmakeConnectionassertInconnectionsconnectionLostassertNotIn)r'   r^   r   s   &  r.   (test_tcpDisconnectRemovesFromConnections6ResolverTests.test_tcpDisconnectRemovesFromConnections  sp    
 ??,?+@A##11$7%h 4 45 	%#7#78r1   c                   \         P                  ! 4       p\        P                  ! R.VR7      pVP	                  \
        P                  ! R4      4      pVP                  ^ ,          w  rErgp ! R R\        4      p	VP                  VP                  ^ ,          \        P                  ! V	! 4       4      4       V P                  W94       R# )z
The deferred returned by L{client.Resolver.queryTCP} will
errback when the TCP connection attempt fails. The reason for
the connection failure is passed as the argument to errback.
r@  r   c                       ] tR tRtRtR# )VResolverTests.test_singleTCPQueryErrbackOnConnectionFailure.<locals>.SentinelExceptioni  r2   Nr  r2   r1   r.   SentinelExceptionr    r  r1   r  Nz192.0.2.100r   )r   r+  r   rp   queryTCPr   r   
tcpClientsr  clientConnectionFailed
connectorsr   r  failureResultOf)
r'   r   r^   r  rC  r$  r  r)   bindAddressr  s
   &         r.   -test_singleTCPQueryErrbackOnConnectionFailure;ResolverTests.test_singleTCPQueryErrbackOnConnectionFailure  s      --/??,?+@'Rcii674;4F4Fq4I1Gk		 	 	&&q!7??3D3F#G	
 	Q2r1   c                    \         P                  ! 4       p\        P                  ! R.VR7      pVP	                  \
        P                  ! R4      4      pVP	                  \
        P                  ! R4      4      pVP                  ^ ,          w  rVrxp	 ! R R\        4      p
VP                  VP                  ^ ,          \        P                  ! V
! 4       4      4       V P                  W:4      pV P                  WJ4      pV P                  W4       R# )zy
All pending L{resolver.queryTCP} C{deferred}s will C{errback}
with the same C{Failure} if the connection attempt fails.
r@  r   zexample.netc                       ] tR tRtRtR# )XResolverTests.test_multipleTCPQueryErrbackOnConnectionFailure.<locals>.SentinelExceptioni  r2   Nr  r2   r1   r.   r  r    r  r1   r  Nr  )r   r+  r   rp   r  r   r   r  r  r  r  r   r  r  rb   )r'   r   r^   d1d2rC  r$  r  r)   r  r  f1f2s   &            r.   /test_multipleTCPQueryErrbackOnConnectionFailure=ResolverTests.test_multipleTCPQueryErrbackOnConnectionFailure  s    
  --/??,?+@'Rsyy78syy784;4F4Fq4I1Gk		 	 	&&q!7??3D3F#G	
 !!"8!!"8br1   c                  aa \         P                  ! 4       p\        P                  ! R.VR7      o\        P
                  ! R4      oSP                  S4      pVV3R lpVP                  V4       V P                  \        VP                  4      ^4       V P                  \        VP                  4      ^4       VP                  ^ ,          w  rErgp\        P                  ! \        4       4      p	VP                  VP                  ^ ,          V	4       V P                  \        VP                  4      ^4       V P                  \        VP                  4      ^4       V P!                  V4       \        P                  ! \        4       4      p
VP                  VP                  ^,          V
4       V P#                  V\        4      pV P%                  W4       R# )zc
An errback on the deferred returned by
L{client.Resolver.queryTCP} may trigger another TCP query.
r@  r   c                 P   < V P                  \        4       SP                  S4      # rG   )trapr   r  )eqr^   s   &r.   reissueOResolverTests.test_reentrantTCPQueryErrbackOnConnectionFailure.<locals>.reissue  s!    FF)*$$Q''r1   N)r   iE'  )r   r+  r   rp   r   r   r  
addErrbackrq   rr   r  r  r   r  r   r  assertNoResultr  rb   )r'   r   r  r  rC  r$  r  r)   r  r  r  fr  r^   s   &           @@r.   0test_reentrantTCPQueryErrbackOnConnectionFailure>ResolverTests.test_reentrantTCPQueryErrbackOnConnectionFailure  sl   
  --/??,@+A7SIIm$ a 	( 	
WW//0!4W//0!44;4F4Fq4I1Gk __356&&w'9'9!'<bA 	W//0!4W//0!4A __356&&w'9'9!'<bA   $:;ar1   c                N   \         P                  ! 4       p\        P                  ! R.VR7      pVP	                  \
        P                  ! R4      4      pVP                  ^ ,          w  rErgpVP                  p	V P                  \        V	4      ^4        ! R R\        4      p
VP                  VP                  ^ ,          \        P                  ! V
! 4       4      4       V P!                  W:4       V P#                  VP                  V	4       V P                  \        V	4      ^ 4       R# )z
When the TCP connection attempt fails, the
L{client.Resolver.pending} list is emptied in place. It is not
replaced with a new empty list.
r@  r   c                       ] tR tRtRtR# )JResolverTests.test_pendingEmptiedInPlaceOnError.<locals>.SentinelExceptioni'  r2   Nr  r2   r1   r.   r  r  '  r  r1   r  Nr  )r   r+  r   rp   r  r   r   r  pendingrq   rr   r  r  r  r   r  r  rb   )r'   r   r^   r  rC  r$  r  r)   r  
prePendingr  s   &          r.   !test_pendingEmptiedInPlaceOnError/ResolverTests.test_pendingEmptiedInPlaceOnError  s      --/??,?+@'Rcii674;4F4Fq4I1Gk%%
Z!,		 	 	&&q!7??3D3F#G	
 	Q2h&&
3Z!,r1   r2   N)#r3   r4   r5   r6   rC   r   r   r   r   r   r   r   r   r  r  r  r  r(  r-  r=  rE  rU  r\  ri  rz  r  r  r  r  r  r  r  r  r7   r8   r9   s   @r.   r   r      s     (07C+$/. D#J*6*0
6
.	/1,
*-&+&(,10=2=4B>93*.)V- -r1   r   c                      a  ] tR tRt o R tR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR t Rt!V t"R # )!ClientTestsi3  c                H    \        4       \        n        RV n        RV n        R# )z*
Replace the resolver with a FakeResolver
   example.comr   N)r   r   theResolverhostnamehostnameForGetHostByNamer@   s   &r.   setUpClientTests.setUp4  s     *^&(<%r1   c                    R\         n        R# )zX
By setting the resolver to None, it will be recreated next time a name
lookup is done.
N)r   r  r@   s   &r.   tearDownClientTests.tearDown<  s    
 "r1   c                    Vw  r4pV^ ,          pV P                  VP                  P                  V P                  4       V P                  VP                  V4       R# )zD
Verify that the result is the same query type as what is expected.
N)rq   r   r  r    )r'   r+   r(   r   r,   r-   rR   s   &&&    r.   checkResultClientTests.checkResultC  sI     *1&J))4==9e,r1   c                *    V P                  VR4       R# )zB
Test that the getHostByName query returns the 127.0.0.1 address.
r   Nr   r'   rR   s   &&r.   checkGetHostByNameClientTests.checkGetHostByNameL  s     	-r1   c                |    \         P                  ! V P                  4      pVP                  V P                  4       V# )z=
do a getHostByName of a value that should return 127.0.0.1.
)r   getHostByNamer  r   r  r'   r  s   & r.   test_getHostByNameClientTests.test_getHostByNameR  s1       !>!>?	d--.r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# )z
Do a lookup and test that the resolver will issue the correct type of
query type. We do this by checking that FakeResolver returns a result
record with the same query type as what we issued.
)r   lookupAddressr  r   r  r   r$   r  s   & r.   test_lookupAddressClientTests.test_lookupAddressZ  s5       /	d&&.r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# z
See L{test_lookupAddress}
)r   lookupIPV6Addressr  r   r  r   AAAAr  s   & r.   test_lookupIPV6Address"ClientTests.test_lookupIPV6Addressd  s5     $$T]]3	d&&1r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupAddress6r  r   r  r   r  r  s   & r.   test_lookupAddress6ClientTests.test_lookupAddress6l  s5     !!$--0	d&&/r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupNameserversr  r   r  r   NSr  s   & r.   test_lookupNameservers"ClientTests.test_lookupNameserverst  s5     $$T]]3	d&&/r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupCanonicalNamer  r   r  r   CNAMEr  s   & r.   test_lookupCanonicalName$ClientTests.test_lookupCanonicalName|  s5     &&t}}5	d&&		2r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupAuthorityr  r   r  r   SOAr  s   & r.   test_lookupAuthority ClientTests.test_lookupAuthority  s5     ""4==1	d&&0r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupMailBoxr  r   r  r   MBr  s   & r.   test_lookupMailBoxClientTests.test_lookupMailBox  s5       /	d&&/r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupMailGroupr  r   r  r   MGr  s   & r.   test_lookupMailGroup ClientTests.test_lookupMailGroup  s5     ""4==1	d&&/r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupMailRenamer  r   r  r   MRr  s   & r.   test_lookupMailRename!ClientTests.test_lookupMailRename  s5     ##DMM2	d&&/r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   
lookupNullr  r   r  r   NULLr  s   & r.   test_lookupNullClientTests.test_lookupNull  5     dmm,	d&&1r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupWellKnownServicesr  r   r  r   WKSr  s   & r.   test_lookupWellKnownServices(ClientTests.test_lookupWellKnownServices  s5     **4==9	d&&0r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupPointerr  r   r  r   PTRr  s   & r.   test_lookupPointerClientTests.test_lookupPointer  5       /	d&&0r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupHostInfor  r   r  r   HINFOr  s   & r.   test_lookupHostInfoClientTests.test_lookupHostInfo  s5     !!$--0	d&&		2r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupMailboxInfor  r   r  r   MINFOr  s   & r.   test_lookupMailboxInfo"ClientTests.test_lookupMailboxInfo  5     $$T]]3	d&&		2r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupMailExchanger  r   r  r   MXr  s   & r.   test_lookupMailExchange#ClientTests.test_lookupMailExchange  s5     %%dmm4	d&&/r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   
lookupTextr  r   r  r   TXTr  s   & r.   test_lookupTextClientTests.test_lookupText  s5     dmm,	d&&0r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupSenderPolicyr  r   r  r   SPFr  s   & r.   test_lookupSenderPolicy#ClientTests.test_lookupSenderPolicy  s5     %%dmm4	d&&0r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupResponsibilityr  r   r  r   RPr  s   & r.   test_lookupResponsibility%ClientTests.test_lookupResponsibility  s5     ''6	d&&/r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupAFSDatabaser  r   r  r   AFSDBr  s   & r.   test_lookupAFSDatabase"ClientTests.test_lookupAFSDatabase  r1  r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupServicer  r   r  r   SRVr  s   & r.   test_lookupServiceClientTests.test_lookupService  r&  r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   
lookupZoner  r   r  r   AXFRr  s   & r.   test_lookupZoneClientTests.test_lookupZone  r  r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupAllRecordsr  r   r  r   ALL_RECORDSr  s   & r.   test_lookupAllRecords!ClientTests.test_lookupAllRecords  s5     ##DMM2	d&&8r1   c                    \         P                  ! V P                  4      pVP                  V P                  \
        P                  4       V# r  )r   lookupNamingAuthorityPointerr  r   r  r   NAPTRr  s   & r.   !test_lookupNamingAuthorityPointer-ClientTests.test_lookupNamingAuthorityPointer  s5     //>	d&&		2r1   c                    \         P                  ! V P                  \         P                  4      p\        P
                  ! V4      pVP                  V P                  \         P                  4       V# )z
L{client.query} accepts a L{dns.Query} instance and dispatches
it to L{client.theResolver}.C{query}, which in turn dispatches
to an appropriate C{lookup*} method of L{client.theResolver},
based on the L{dns.Query} type.
)r   r   r  r$   r   rS   r   r  )r'   r  r  s   &  r.   
test_queryClientTests.test_query  sF     IIdmmSUU+LLO	d&&.r1   )r  r  N)#r3   r4   r5   r6   r  r  r  r  r  r  r  r  r  r   r  r
  r  r  r  r  r$  r*  r/  r5  r:  r?  rD  rI  rN  rS  rX  r]  r`  r7   r8   r9   s   @r.   r  r  3  s     ="-.
 
r1   r  c                   Z   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tRtV tR# )FilterAnswersTestsi!  zp
Test L{twisted.names.client.Resolver.filterAnswers}'s handling of various
error conditions it might encounter.
c                @    \         P                  ! R.R7      V n        R# )0.0.0.0r   N)re  rr  )r   rp   r^   r@   s   &r.   r  FilterAnswersTests.setUp'  s     0@Ar1   c                  a a \         P                  ! RR7      oSP                  R4       VV 3R lpVS P                  n        S P                  P                  S4      pVP                  S P                  R.R.R.34       V# )zN
Test that a truncated message results in an equivalent request made via
TCP.
T)truncr  c                    < SP                  V SP                  4       \        P                  ! 4       pR .Vn        R.Vn        R.Vn        \        P                  ! V4      # )r   r,   r-   )	rq   rI   r   r   r   r,   r-   r   r&   )rI   r   mr'   s   & r.   r  :FilterAnswersTests.test_truncatedMessage.<locals>.queryTCP4  sO    Waii0{{}H (zH"-H#/.H==**r1   r   r,   r-   )r   r   addQueryr^   r  filterAnswersr   rq   )r'   r  r  rj  s   f  @r.   test_truncatedMessage(FilterAnswersTests.test_truncatedMessage,  sl    
 KKd#	

>"	+ "*MM''*	d&&(k]\N(STr1   c                    \         P                  ! VR 7      pV P                  P                  V4      pVP	                  V4       R# ))rCodeN)r   r   r^   rm  r  )r'   rcoderh  rj  re  s   &&&  r.   
_rcodeTestFilterAnswersTests._rcodeTestA  s/    KKe$mm))!,r1   c                ^    V P                  \        P                  \        P                  4      # )zm
Test that a message with a result code of C{EFORMAT} results in a
failure wrapped around L{DNSFormatError}.
)rs  r   EFORMATr   DNSFormatErrorr@   s   &r.   test_formatError#FilterAnswersTests.test_formatErrorF  s    
 s{{E,@,@AAr1   c                ^    V P                  \        P                  \        P                  4      # )z@
Like L{test_formatError} but for C{ESERVER}/L{DNSServerError}.
)rs  r   ESERVERr   DNSServerErrorr@   s   &r.   test_serverError#FilterAnswersTests.test_serverErrorM  s     s{{E,@,@AAr1   c                ^    V P                  \        P                  \        P                  4      # )z<
Like L{test_formatError} but for C{ENAME}/L{DNSNameError}.
)rs  r   ENAMEr   DNSNameErrorr@   s   &r.   test_nameError!FilterAnswersTests.test_nameErrorS  s     syy%*<*<==r1   c                ^    V P                  \        P                  \        P                  4      # )zH
Like L{test_formatError} but for C{ENOTIMP}/L{DNSNotImplementedError}.
)rs  r   ENOTIMPr   DNSNotImplementedErrorr@   s   &r.   test_notImplementedError+FilterAnswersTests.test_notImplementedErrorY  s     s{{E,H,HIIr1   c                ^    V P                  \        P                  \        P                  4      # )zG
Like L{test_formatError} but for C{EREFUSED}/L{DNSQueryRefusedError}.
)rs  r   EREFUSEDr   DNSQueryRefusedErrorr@   s   &r.   test_refusedError$FilterAnswersTests.test_refusedError_  s     s||U-G-GHHr1   c                l    V P                  \        P                  ^,           \        P                  4      # )zU
Like L{test_formatError} but for an unrecognized error code and
L{DNSUnknownError}.
)rs  r   r  r   DNSUnknownErrorr@   s   &r.   test_refusedErrorUnknown+FilterAnswersTests.test_refusedErrorUnknowne  s$    
 s||a/1F1FGGr1   )r^   N)r3   r4   r5   r6   rC   r  rn  rs  rx  r}  r  r  r  r  r7   r8   r9   s   @r.   rc  rc  !  sC     
B
*
BB>JIH Hr1   rc  c                   6   a  ] tR tRt o R tRR ltR tRtV tR# )FakeDNSDatagramProtocolim  c                2    . V n         \        4       V n        R # rG   rH   r@   s   &r.   rK    FakeDNSDatagramProtocol.__init__n  rM   r1   Nc                    V P                   P                  WW434       \        P                  ! \        P
                  ! V4      4      # rG   )rI   rP   r   ry  r   r   )r'   r   rI   r)   rQ   s   &&&&&r.   rS   FakeDNSDatagramProtocol.queryr  s3    Ww;<zz%44W=>>r1   c                    R # rG   r2   )r'   rQ   s   &&r.   removeResend$FakeDNSDatagramProtocol.removeResendv  s    r1   rU   rV   )	r3   r4   r5   r6   rK   rS   r  r7   r8   r9   s   @r.   r  r  m  s     $? r1   r  c                   >   a  ] tR tRt o Rt. ROtR tR tR tRt	V t
R# )	RetryLogicTestsi{  z=
Tests for query retrying implemented by L{client.Resolver}.
c                (  a V P                    Uu. uF  q^53NK  	  pp\        P                  ! RVR7      p\        4       oV3R lVn        VP                  R4      P                  V P                  4      P                  V P                  S4      # u upi )z
When timeouts occur waiting for responses to queries, the next
configured server is issued the query.  When the query has been issued
to all configured servers, the timeout is increased and the process
begins again at the beginning.
N)r   r   c                     < S # rG   r2   )r,  s   r.   r   8RetryLogicTests.test_roundRobinBackoff.<locals>.<lambda>  s    ur1   r   )
testServersr   rp   r  r   r  r   _cbRoundRobinBackoffr  _ebRoundRobinBackoff)r'   xaddrsrv   r,  s   &   @r.   test_roundRobinBackoff&RetryLogicTests.test_roundRobinBackoff  s|     #'"2"23"2QR"23OO47'),OO./[223Z1159	
	 4s   Bc                (    V P                  R 4       R# )z/Lookup address succeeded, should have timed outN)ry  r  s   &&r.   r  $RetryLogicTests._cbRoundRobinBackoff  s    		CDr1   c                   VP                   ! \        P                  4       R F  pVP                  R\	        V P
                  4       pVP                  R\	        V P
                  4      1 VP                  4        \        V P
                  4      pVP                  4        \        WE4       F-  w  w  rgrp
V P                  Wj^534       V P                  W4       K/  	  K  	  V P                  VP                  4       R# )rm   N)rm         -   )r  r   TimeoutErrorrI   rr   r  sortlistziprq   r  )r'   r   	fakeProtottriesexpectedaddrrS   r)   rQ   expectedAddrs   &&&        r.   r  $RetryLogicTests._ebRoundRobinBackoff  s    U''(
  A%%&=D,<,<(=>E!!"9C(8(8$9"9:JJLD,,-HMMO<?<P8*gL  b'9:  , =Q   	**+r1   r2   N)z1.2.3.4z4.3.2.1za.b.c.dzz.y.x.w)r3   r4   r5   r6   rC   r  r  r  r  r7   r8   r9   s   @r.   r  r  {  s&      ?K
"E, ,r1   r  c                   *   a  ] tR tRt o RtR tRtV tR# )ThreadedResolverTestsi  z'
Tests for L{client.ThreadedResolver}.
c                (   \         P                  ! 4        V P                  V P                  .R7      pV P	                  V^ ,          R,          R4       V P	                  V^ ,          R,          \
        4       V P	                  \        V4      ^4       R# )z
L{client.ThreadedResolver} is deprecated.  Instantiating it emits a
deprecation warning pointing at the code that does the instantiation.
)offendingFunctionsmessagezztwisted.names.client.ThreadedResolver is deprecated since Twisted 9.0, use twisted.internet.base.ThreadedResolver instead.categoryN)r   ThreadedResolverflushWarningstest_deprecatedrq   DeprecationWarningrr   )r'   warningss   & r.   r  %ThreadedResolverTests.test_deprecated  s{    
 	!%%$:N:N9O%PQK	"	
 	!Z02DEX*r1   r2   N)r3   r4   r5   r6   rC   r  r7   r8   r9   s   @r.   r  r    s     + +r1   r  )6rC   rc  zope.interface.verifyr   r   twisted.internetr   twisted.internet.errorr   r   twisted.internet.interfacesr   twisted.internet.taskr   #twisted.internet.test.modulehelpersr	   twisted.namesr
   r   r   r   r   twisted.names.commonr   twisted.names.errorr   twisted.names.testr   twisted.names.test.test_hostsr   twisted.pythonr   twisted.python.filepathr   twisted.python.runtimer   twisted.testr   twisted.trialr   	isWindowsrg   r   r<   rE   TestCaserY   rj   r   r  rc  r  r  r  r2   r1   r.   <module>r     s  
  ; " L 1 ' @ : : - 4 ( ; " , + & "KNK?< ?0! ! .x(( 4o&(++-> o&dC	-H%% C	-Lk(## k\IH** IHX -,h'' -,`+H-- +r1   