ϪfJ ddlZddlZddlmZddlmZmZmZmZddl m Z ddl m Z ddl mZmZe j Z ej$dZGd d ZGd d eZGd deeZGddeeZGddeeZGddeeZeedGddeZeedGddeeZy#e$rdZY~wxYw)N)skipIf)HostnameAddress IPv4Address IPv6Address UNIXAddress) nativeString)platform)SynchronousTestCaseTestCaseFTc$eZdZdZdZdZdZy)AddressTestCaseMixinc|j|j|jk(|j|j|jk7y)a Two different address instances, sharing the same properties are considered equal by C{==} and not considered not equal by C{!=}. Note: When applied via UNIXAddress class, this uses the same filename for both objects being compared. N) assertTrue buildAddress assertFalseselfs D/usr/lib/python3/dist-packages/twisted/internet/test/test_address.pytest_addressComparisonz+AddressTestCaseMixin.test_addressComparisonsL ))+t/@/@/BBC **,0A0A0CCDcp|j}|di}|j||jy)z C{__hash__} can be used to get a hash of an address, allowing addresses to be used as keys in dictionaries, for instance. TNrrraddrds r test_hashzAddressTestCaseMixin.test_hash)5   " 4L $++-./rc|j|j|jk(|j|j|jk(|j|j|jk7|j|j|jk7y)z~ Check that comparison operators work correctly on address objects when a different name is passed in N)rrbuildDifferentAddressrrs rtest_differentNamesComparisonz2AddressTestCaseMixin.test_differentNamesComparison2s **,0J0J0LLM 3359J9J9LLM ))+t/I/I/KKL 2248I8I8KKLrc|j|g}|j|ddt|j|dd||jt|dy)z{ Assert that the a DeprecationWarning with the given message was emitted against the given method. rcategorymessageN) flushWarnings assertEqualDeprecationWarninglen)r testMethodr#warningss rassertDeprecationsz'AddressTestCaseMixin.assertDeprecations=s] %%zl3 !Z02DE !Y/9 X*rN)__name__ __module__ __qualname__rrr r+rrr r s E0 M+rr ceZdZdZy)IPv4AddressTestCaseMixin)type%s)host%rportz%dN)r,r-r.addressArgSpecr/rrr1r1HsENrr1c eZdZdZdZdZdZy)HostnameAddressTestsz+ Test case for L{HostnameAddress}. ))hostnamer4r7ctddS)zw Create an arbitrary new L{HostnameAddress} instance. @return: A L{HostnameAddress} instance. s example.comrrrs rrz!HostnameAddressTests.buildAddressS ~q11rctddS)zw Like L{buildAddress}, but with a different hostname. @return: A L{HostnameAddress} instance. s example.netrr>rs rrz*HostnameAddressTests.buildDifferentAddress[r?rN)r,r-r.__doc__r9rrr/rrr;r;Ls:N22rr;ceZdZdZdZy)IPv4AddressTCPTestsctdddS)z Create an arbitrary new L{IPv4Address} instance with a C{"TCP"} type. A new instance is created for each call, but always for the same address. TCP 127.0.0.1rrrs rrz IPv4AddressTCPTests.buildAddresse 5+q11rctdddS)K Like L{buildAddress}, but with a different fixed address. rE 127.0.0.2rrGrs rrz)IPv4AddressTCPTests.buildDifferentAddressm5+q11rNr,r-r.rrr/rrrCrCd 22rrCceZdZdZdZy)IPv4AddressUDPTestsctdddS)z Create an arbitrary new L{IPv4Address} instance with a C{"UDP"} type. A new instance is created for each call, but always for the same address. UDPrFrrGrs rrz IPv4AddressUDPTests.buildAddressurHrctdddS)rJrRrKrrGrs rrz)IPv4AddressUDPTests.buildDifferentAddress}rLrNrMr/rrrPrPtrNrrPceZdZdZdZdZy)IPv6AddressTestsr2ctdddS)z Create an arbitrary new L{IPv6Address} instance with a C{"TCP"} type. A new instance is created for each call, but always for the same address. rEz::1rrrs rrzIPv6AddressTests.buildAddresss 5%++rctdddS)rJrEz::2rrWrs rrz&IPv6AddressTests.buildDifferentAddresss5%++rN)r,r-r.r9rrr/rrrUrUsEN,,rrUz&Platform doesn't support UNIX sockets.cdeZdZdZdZdZdZdZee ddZ ee ddZ y ) UNIXAddressTests)namer6cX|j|_|j|_yN)mktemp_socketAddress _otherAddressrs rsetUpzUNIXAddressTests.setUps"kkm![[]rc,t|jS)z Create an arbitrary new L{UNIXAddress} instance. A new instance is created for each call, but always for the same address. rr`rs rrzUNIXAddressTests.buildAddresss 4..//rc,t|jS)rJ)rrars rrz&UNIXAddressTests.buildDifferentAddresss4--..rc|jt|jdt|jzy)zn The repr of L{UNIXAddress} returns with the filename that the L{UNIXAddress} is for. zUNIXAddress('%s')N)r&reprrrr`rs r test_reprzUNIXAddressTests.test_reprs6  ""$ % <0C0C#D E r"Platform does not support symlinksc|j}t|jd5|_t j tj j|j||jt|jt||jt|t|jdddy#1swYyxYw)zU UNIXAddress objects compare as equal if they link to the same file. wN) r_openr`fdossymlinkpathabspathr&rrlinkNames rtest_comparisonOfLinkedFilesz-UNIXAddressTests.test_comparisonOfLinkedFiless ;;= $%%s + Vtw JJrwwt':':;X F   [)<)<={8?T U   [2K@S@S4T U V V V BCCc ~|j}t|jd5|_t j tj j|j||jtt|jtt|dddy#1swYyxYw)zU UNIXAddress Objects that compare as equal have the same hash value. rkN) r_rlr`rmrnrorprqr&hashrrrs rtest_hashOfLinkedFilesz'UNIXAddressTests.test_hashOfLinkedFiless ;;= $%%s + tw JJrwwt':':;X F   [!4!456[=R8S    s BB33B<N) r,r-r.r9rbrrrhr symlinkSkiprtrxr/rrrZrZsU&N+0/   K=>V?V K=> ? rrZz&platform doesn't support UNIX sockets.cJeZdZdZdZdZdZdZee ddZ dZ y ) EmptyUNIXAddressTestszJ Tests for L{UNIXAddress} operations involving a L{None} address. r[c.|j|_yr^)r_r`rs rrbzEmptyUNIXAddressTests.setUps"kkmrctdS)z Create an arbitrary new L{UNIXAddress} instance. A new instance is created for each call, but always for the same address. This builds it with a fixed address of L{None}. N)rrs rrz"EmptyUNIXAddressTests.buildAddresss 4  rc,t|jS)zN Like L{buildAddress}, but with a random temporary directory. rdrs rrz+EmptyUNIXAddressTests.buildDifferentAddresss4..//rric|j}t|jd5|_t j tj j|j||jt|jtd|jtdt|jdddy#1swYyxYw)z A UNIXAddress referring to a L{None} address does not compare equal to a UNIXAddress referring to a symlink. rkN) r_rlr`rmrnrorprqassertNotEqualrrrs rrtz2EmptyUNIXAddressTests.test_comparisonOfLinkedFiless ;;= $%%s + Utw JJrwwt':':;X F    D,?,? @+dBS T    D 1;t?R?R3S T U U Urucp|j}|di}|j||jy)z C{__hash__} can be used to get a hash of an address, even one referring to L{None} rather than a real path. TNrrs rtest_emptyHashz$EmptyUNIXAddressTests.test_emptyHashrrN) r,r-r.rAr9rbrrrryrtrr/rrr{r{s@'N,!0  K=> U? U0rr{)rnsocketunittestrtwisted.internet.addressrrrrtwisted.python.compatrtwisted.python.runtimer twisted.trial.unittestr r _supportsSymlinksryAF_UNIXunixSkipAttributeErrorr r1r;rCrPrUrZr{r/rrrs   /+@,(,,..  NNH(+(+VF3F28%920 2-/G 2 2-/G 2 ,*,@,$:;3*3<3l:;+0/1E+0<+0oHs CCC