HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/twisted/trial/test/__pycache__/test_util.cpython-38.pyc
U

��W[�`�@sLdZddlmZmZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZmZmZmZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de �Z!Gdd�de �Z"Gdd�de�Z#Gdd�de�Z$Gdd�de�Z%Gdd�de�Z&Gd d!�d!e�Z'dS)"z!
Tests for L{twisted.trial.util}
�)�division�absolute_importN)�implementer)�NativeStringIO)�filepath)�IProcessTransport)�defer)�DelayedCall)�Failure)�SynchronousTestCase)�util)�DirtyReactorAggregateError�_Janitor�excInfoOrFailureToExcInfo�acquireAttributec@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�MktempTestszm
    Tests for L{TestCase.mktemp}, a helper function for creating temporary file
    or directory names.
    cCs:|��}tj�|��tj�dd�}|�|dddg�dS)z�
        The path name returned by C{mktemp} is directly beneath a directory
        which identifies the test method which created the name.
        N���ztwisted.trial.test.test_utilr�	test_name)�mktemp�os�path�dirname�split�sep�assertEqual)�self�name�dirs�r�>/usr/lib/python3/dist-packages/twisted/trial/test/test_util.pyr#s�zMktempTests.test_namecCs|��}|�||���dS)zF
        Repeated calls to C{mktemp} return different values.
        N)rZassertNotEqual)rrrrr�test_unique.szMktempTests.test_uniquecCs<|��}tj�|�}|�tj�|��|�tj�|��dS)zS
        The directory part of the path name returned by C{mktemp} exists.
        N)rrrr�
assertTrue�exists�assertFalse)rrrrrr�test_created6szMktempTests.test_createdcCs(tj�|���}|�|�t����dS)zZ
        The path returned by C{mktemp} is beneath the current working directory.
        N)rr�abspathrr!�
startswith�getcwd)rrrrr�
test_location@szMktempTests.test_locationN)�__name__�
__module__�__qualname__�__doc__rr r$r(rrrrrs

rc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�RunSequentiallyTestsz�
    Sometimes it is useful to be able to run an arbitrary list of callables,
    one after the other.

    When some of those callables can return Deferreds, things become complex.
    cOs(g}|�|j�||df|�|�dS)ze
        Call the given assertion function against the current result of a
        Deferred.
        rN)ZaddCallback�append)rZdeferredZassertFunction�args�kwargs�resultrrr�assertDeferredResultQsz)RunSequentiallyTests.assertDeferredResultcCst�g�}|�||jg�dS)z�
        When asked to run an empty list of callables, runSequentially returns a
        successful Deferred that fires an empty list.
        N)r�_runSequentiallyr2r�r�drrr�test_emptyListZs
z#RunSequentiallyTests.test_emptyListcCs,t�dd�g�}|�||jtjdfg�dS)z�
        When given a callable that succeeds without returning a Deferred,
        include the return value in the results list, tagged with a SUCCESS
        flag.
        cSsdS�Nrrrrr�<lambda>i�zDRunSequentiallyTests.test_singleSynchronousSuccess.<locals>.<lambda>N�rr3r2rr�SUCCESSr4rrr�test_singleSynchronousSuccesscsz2RunSequentiallyTests.test_singleSynchronousSuccesscs0t��fdd�g�}�fdd�}��||�dS)z�
        When given a callable that raises an exception, include a Failure for
        that exception in the results list, tagged with a FAILURE flag.
        cs
��d�S�N�foo��failr�rrrr8rr9zDRunSequentiallyTests.test_singleSynchronousFailure.<locals>.<lambda>cs8|\\}}|��j���|��d���|tj�dSr=)�trap�failureExceptionr�getErrorMessager�FAILURE��results�flagr@rArr�checkss
zARunSequentiallyTests.test_singleSynchronousFailure.<locals>.checkN�rr3r2�rr5rIrrAr�test_singleSynchronousFailuremsz2RunSequentiallyTests.test_singleSynchronousFailurecCs,t�dd�g�}|�||jtjdfg�dS)z�
        When given a callable that returns a successful Deferred, include the
        result of the Deferred in the results list, tagged with a SUCCESS flag.
        cSs
t�d�Sr7)rZsucceedrrrrr8�r9zERunSequentiallyTests.test_singleAsynchronousSuccess.<locals>.<lambda>Nr:r4rrr�test_singleAsynchronousSuccess{sz3RunSequentiallyTests.test_singleAsynchronousSuccesscs,t�dd�g�}�fdd�}��||�dS)z�
        When given a callable that returns a failing Deferred, include the
        failure the results list, tagged with a FAILURE flag.
        cSst�td��Sr=)rr@�
ValueErrorrrrrr8�r9zERunSequentiallyTests.test_singleAsynchronousFailure.<locals>.<lambda>cs6|\\}}|�t���|��d���|tj�dSr=)rBrNrrDrrErFrArrrI�s

zBRunSequentiallyTests.test_singleAsynchronousFailure.<locals>.checkNrJrKrrAr�test_singleAsynchronousFailure�sz3RunSequentiallyTests.test_singleAsynchronousFailurecsdg�g���fdd��t��fdd��fdd�g�|��dg��d�d�|��dd	g�dS)
zf
        Check that the callables are called in the given order, one after the
        other.
        cs t��}��|���|�|Sr7)rZDeferredr.)�valuer5)�	deferreds�logrrr.�s

z@RunSequentiallyTests.test_callablesCalledInOrder.<locals>.appendcs�d�Sr=rr�r.rrr8�r9zBRunSequentiallyTests.test_callablesCalledInOrder.<locals>.<lambda>cs�d�S�N�barrrrSrrr8�r9r>rNrU)rr3r�callbackrAr)r.rQrRr�test_callablesCalledInOrder�s
�z0RunSequentiallyTests.test_callablesCalledInOrdercs6t��fdd�dd�g�}�fdd�}��||�dS)z�
        If one of the callables raises an error, then runSequentially continues
        to run the remaining callables.
        cs
��d�Sr=r?rrArrr8�r9z?RunSequentiallyTests.test_continuesAfterError.<locals>.<lambda>cSsdSrTrrrrrr8�r9csX|\\}}\}}|��j���|tj���|��d���|tj���|d�dS)Nr>rU)rBrCrrrErDr;)rG�flag1r@Zflag2r1rArrrI�sz<RunSequentiallyTests.test_continuesAfterError.<locals>.checkNrJrKrrAr�test_continuesAfterError�sz-RunSequentiallyTests.test_continuesAfterErrorcs:tj�fdd�dd�gdd�}�fdd�}��||�dS)	z�
        If the C{stopOnFirstError} option is passed to C{runSequentially}, then
        no further callables are called after the first exception is raised.
        cs
��d�Sr=r?rrArrr8�r9z<RunSequentiallyTests.test_stopOnFirstError.<locals>.<lambda>cSsdSrTrrrrrr8�r9T)ZstopOnFirstErrorcs8|\\}}|��j���|tj���|��d�dSr=)rBrCrrrErD)rGrXr@rArrrI�s
z9RunSequentiallyTests.test_stopOnFirstError.<locals>.checkNrJrKrrAr�test_stopOnFirstError�s
�z*RunSequentiallyTests.test_stopOnFirstErrorN)
r)r*r+r,r2r6r<rLrMrOrWrYrZrrrrr-Is		
	r-c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�DirtyReactorAggregateErrorTestsz6
    Tests for the L{DirtyReactorAggregateError}.
    cCs tddg�}|�t|�d�dS)z5
        Delayed calls are formatted nicely.
        ZFoorUzhReactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
Foo
barN�r
r�str�r�errorrrr�test_formatDelayedCall�s
�z6DirtyReactorAggregateErrorTests.test_formatDelayedCallcCs"tgddg�}|�t|�d�dS)z3
        Selectables are formatted nicely.
        zselectable 1zselectable 2z;Reactor was unclean.
Selectables:
selectable 1
selectable 2Nr\r^rrr�test_formatSelectables�s
�z6DirtyReactorAggregateErrorTests.test_formatSelectablescCs&tddgddg�}|�t|�d�dS)zR
        Both delayed calls and selectables can appear in the same error.
        ZbleckZBoozoZSel1ZSel2z�Reactor was unclean.
DelayedCalls: (set twisted.internet.base.DelayedCall.debug = True to debug)
bleck
Boozo
Selectables:
Sel1
Sel2Nr\r^rrr�%test_formatDelayedCallsAndSelectables�s�
�zEDirtyReactorAggregateErrorTests.test_formatDelayedCallsAndSelectablesN)r)r*r+r,r`rarbrrrrr[�s

r[c@s4eZdZdZddd�Zddd�Zdd�Zd	d
�ZdS)
�StubReactora~
    A reactor stub which contains enough functionality to be used with the
    L{_Janitor}.

    @ivar iterations: A list of the arguments passed to L{iterate}.
    @ivar removeAllCalled: Number of times that L{removeAll} was called.
    @ivar selectables: The value that will be returned from L{removeAll}.
    @ivar delayedCalls: The value to return from L{getDelayedCalls}.
    NcCs$||_g|_d|_|sg}||_dS)z�
        @param delayedCalls: See L{StubReactor.delayedCalls}.
        @param selectables: See L{StubReactor.selectables}.
        rN)�delayedCalls�
iterations�removeAllCalled�selectables)rrdrgrrr�__init__szStubReactor.__init__cCs|j�|�dS)z/
        Increment C{self.iterations}.
        N)rer.)rZtimeoutrrr�iterateszStubReactor.iteratecCs|jS)z.
        Return C{self.delayedCalls}.
        )rdrArrr�getDelayedCallsszStubReactor.getDelayedCallscCs|jd7_|jS)zS
        Increment C{self.removeAllCalled} and return C{self.selectables}.
        �)rfrgrArrr�	removeAll!szStubReactor.removeAll)N)N)r)r*r+r,rhrirjrlrrrrrc�s



rcc@s eZdZdZdd�Zdd�ZdS)�StubErrorReporterz�
    A subset of L{twisted.trial.itrial.IReporter} which records L{addError}
    calls.

    @ivar errors: List of two-tuples of (test, error) which were passed to
        L{addError}.
    cCs
g|_dSr7)�errorsrArrrrh3szStubErrorReporter.__init__cCs|j�||f�dS)z6
        Record parameters in C{self.errors}.
        N)rnr.)r�testr_rrr�addError7szStubErrorReporter.addErrorN)r)r*r+r,rhrprrrrrm*srmc@sheZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�JanitorTestsz 
    Tests for L{_Janitor}!
    cCs4tg�}tdd|d�}|��|�|jddg�dS)a
        During pending-call cleanup, the reactor will be spun twice with an
        instant timeout. This is not a requirement, it is only a test for
        current behavior. Hopefully Trial will eventually not do this kind of
        reactor stuff.
        N��reactorr)rcr�
_cleanPendingrre�rrs�janrrr�test_cleanPendingSpinsReactorDsz*JanitorTests.test_cleanPendingSpinsReactorcCsVdd�}g}td|di|jdd��}t|g�}tdd|d�}|��|�||g�dS)	zW
        During pending-call cleanup, the janitor cancels pending timed calls.
        cSsdS)NZLulzrrrrr�funcUsz8JanitorTests.test_cleanPendingCancelsCalls.<locals>.func�,rcSsdSr7r��xrrrr8Yr9z<JanitorTests.test_cleanPendingCancelsCalls.<locals>.<lambda>Nrr)r	r.rcrrtr)rrxZ	cancelled�delayedCallrsrvrrr�test_cleanPendingCancelsCallsQs
�
z*JanitorTests.test_cleanPendingCancelsCallsc	Cs`tddd�didd�dd�dd�d�}t|�}t|g�}tdd|d	�}|��}|�||g�dS)
aK
        The Janitor produces string representations of delayed calls from the
        delayed call cleanup method. It gets the string representations
        *before* cancelling the calls; this is important because cancelling the
        call removes critical debugging information from the string
        representation.
        rycSsdSr7rrrrrr8hr9zIJanitorTests.test_cleanPendingReturnsDelayedCallStrings.<locals>.<lambda>rcSsdSr7rrzrrrr8ir9cSsdS�Nrrrrrrr8jr9�ZsecondsNrr)r	r]rcrrtr)rr|�delayedCallStringrsrvZstringsrrr�*test_cleanPendingReturnsDelayedCallStrings`s�
z7JanitorTests.test_cleanPendingReturnsDelayedCallStringscCs0tg�}tdd|d�}|��|�|jd�dS)zM
        The Janitor will remove selectables during reactor cleanup.
        Nrrrk)rcr�
_cleanReactorrrfrurrr�#test_cleanReactorRemovesSelectablesrsz0JanitorTests.test_cleanReactorRemovesSelectablescCsTtt�Gdd�dt��}|�}tg|g�}tdd|d�}|��|�|jdg�dS)zI
        The Janitor will kill processes during reactor cleanup.
        c@s eZdZdZdd�Zdd�ZdS)zJJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransportz�
            A stub L{IProcessTransport} provider which records signals.
            @ivar signals: The signals passed to L{signalProcess}.
            cSs
g|_dSr7)�signalsrArrrrh�szSJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.__init__cSs|j�|�dS)zF
                Append C{signal} to C{self.signals}.
                N)r�r.)r�signalrrr�
signalProcess�szXJanitorTests.test_cleanReactorKillsProcesses.<locals>.StubProcessTransport.signalProcessN)r)r*r+r,rhr�rrrr�StubProcessTransport�sr�NrrZKILL)rr�objectrcrr�rr�)rr�Zptrsrvrrr�test_cleanReactorKillsProcesses|sz,JanitorTests.test_cleanReactorKillsProcessescCsBGdd�dt�}tg|�g�}tdd|d�}|�|��dg�dS)z�
        The Janitor returns string representations of the selectables that it
        cleaned up from the reactor cleanup method.
        c@seZdZdZdd�ZdS)zJJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectablezl
            A stub Selectable which only has an interesting string
            representation.
            cSsdS)N�
(SELECTABLE!)rrArrr�__repr__�szSJanitorTests.test_cleanReactorReturnsSelectableStrings.<locals>.Selectable.__repr__N)r)r*r+r,r�rrrr�
Selectable�sr�Nrrr�)r�rcrrr�)rr�rsrvrrr�)test_cleanReactorReturnsSelectableStrings�sz6JanitorTests.test_cleanReactorReturnsSelectableStringscCsBtg�}t�}t�}t|||d�}|�|���|�|jg�dS)z�
        The post-case cleanup method will return True and not call C{addError}
        on the result if there are no pending calls.
        rrN)rcr�rmrr!�postCaseCleanuprrn�rrsro�reporterrvrrr�test_postCaseCleanupNoErrors�sz)JanitorTests.test_postCaseCleanupNoErrorsc	Cs�tddd�didd�dd�dd�d�}t|�}t|gg�}t�}t�}t|||d�}|�|���|�t	|j
�d	�|�|j
d
d	jj|g�dS)z�
        The post-case cleanup method will return False and call C{addError} on
        the result with a L{DirtyReactorAggregateError} Failure if there are
        pending calls.
        rycSsdSr7rrrrrr8�r9z=JanitorTests.test_postCaseCleanupWithErrors.<locals>.<lambda>rcSsdSr7rrzrrrr8�r9cSsdSr~rrrrrr8�r9rrrrkrN)
r	r]rcr�rmrr#r�r�lenrnrPrd�rr|r�rsror�rvrrr�test_postCaseCleanupWithErrors�s��z+JanitorTests.test_postCaseCleanupWithErrorscCs<tg�}t�}t�}t|||d�}|��|�|jg�dS)z�
        The post-class cleanup method will not call C{addError} on the result
        if there are no pending calls or selectables.
        rrN)rcr�rmr�postClassCleanuprrnr�rrr�test_postClassCleanupNoErrors�sz*JanitorTests.test_postClassCleanupNoErrorsc	Cs�tddd�didd�dd�dd�d�}t|�}t|gg�}t�}t�}t|||d�}|��|�t|j	�d	�|�|j	d
d	j
j|g�dS)z�
        The post-class cleanup method call C{addError} on the result with a
        L{DirtyReactorAggregateError} Failure if there are pending calls.
        rycSsdSr7rrrrrr8�r9zIJanitorTests.test_postClassCleanupWithPendingCallErrors.<locals>.<lambda>rcSsdSr7rrzrrrr8�r9cSsdSr~rrrrrr8�r9rrrrkrN)r	r]rcr�rmrr�rr�rnrPrdr�rrr�*test_postClassCleanupWithPendingCallErrors�s��z7JanitorTests.test_postClassCleanupWithPendingCallErrorscCshd}tg|g�}t�}t�}t|||d�}|��|�t|j�d�|�|jddjj	t
|�g�dS)z�
        The post-class cleanup method call C{addError} on the result with a
        L{DirtyReactorAggregateError} Failure if there are selectables.
        zSELECTABLE HERErrrkrN)rcr�rmrr�rr�rnrPrg�repr)rZ
selectablersror�rvrrr�)test_postClassCleanupWithSelectableErrors�s�z6JanitorTests.test_postClassCleanupWithSelectableErrorsN)r)r*r+r,rwr}r�r�r�r�r�r�r�r�r�rrrrrq?s



rqc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�RemoveSafelyTestsz*
    Tests for L{util._removeSafely}.
    cCs8|���d�}t�|�t�|�}|�tjtj	|�dS)z�
        If a path doesn't contain a node named C{"_trial_marker"}, that path is
        not removed by L{util._removeSafely} and a L{util._NoTrialMarker}
        exception is raised instead.
        �utf-8N)
r�encoder�mkdirr�FilePath�assertRaisesrZ_NoTrialMarker�
_removeSafely)r�	directory�dirPathrrr�test_removeSafelyNoTrialMarker�s

z0RemoveSafelyTests.test_removeSafelyNoTrialMarkercCspdd�}t�}|�td|�|���d�}t�|�t�|�}|�	d��
�||_t�
|�|�d|���dS)z�
        If an L{OSError} is raised while removing a path in
        L{util._removeSafely}, an attempt is made to move the path to a new
        name.
        cSs
t��dS)��
            Raise an C{OSError} to emulate the branch of L{util._removeSafely}
            in which path removal fails.
            N��OSErrorrrrr�dummyRemoveszORemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceeds.<locals>.dummyRemove�stdoutr��
_trial_marker�could not remove FilePathN)r�patch�sysrr�rr�rr��child�touch�removerr��assertIn�getvalue)rr��outr�r�rrr�(test_removeSafelyRemoveFailsMoveSucceedss


z:RemoveSafelyTests.test_removeSafelyRemoveFailsMoveSucceedscCs�dd�}dd�}t�}|�td|�|���d�}t�|�t�|�}|�	d��
�||_||_|�
ttj|�}|�t|�d�|�d	|���d
S)z�
        If an L{OSError} is raised while removing a path in
        L{util._removeSafely}, an attempt is made to move the path to a new
        name. If that attempt fails, the L{OSError} is re-raised.
        cSstd��dS)r�zpath removal failedNr�rrrrr�.szLRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyRemovecSstd��dS)z�
            Raise an C{OSError} to emulate the branch of L{util._removeSafely}
            in which path movement fails.
            �path movement failedNr�)rrrr�dummyMoveTo5szLRemoveSafelyTests.test_removeSafelyRemoveFailsMoveFails.<locals>.dummyMoveTor�r�r�r�r�N)rr�r�rr�rr�rr�r�r�r�ZmoveTor�r�rr�rr]r�r�)rr�r�r�r�r�r_rrr�%test_removeSafelyRemoveFailsMoveFails(s

z7RemoveSafelyTests.test_removeSafelyRemoveFailsMoveFailsN)r)r*r+r,r�r�r�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�ExcInfoTestsz1
    Tests for L{excInfoOrFailureToExcInfo}.
    cCs$ttd�df}|�|t|�k�dS)z�
        L{excInfoOrFailureToExcInfo} returns exactly what it is passed, if it is
        passed a tuple like the one returned by L{sys.exc_info}.
        r>N)rNr!r)r�inforrr�test_excInfoTszExcInfoTests.test_excInfocCs@zddWnt�}YnX|�|j|j|jft|��dS)z�
        When called with a L{Failure} instance, L{excInfoOrFailureToExcInfo}
        returns a tuple like the one returned by L{sys.exc_info}, with the
        elements taken from the type, value, and traceback of the failure.
        rkrN)r
r�typerP�tbr)r�frrr�test_failure]s
zExcInfoTests.test_failureN)r)r*r+r,r�r�rrrrr�Ps	r�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�AcquireAttributeTestsz(
    Tests for L{acquireAttribute}.
    cCs*t�|_}|�|t|t�gd�k�dS)z�
        The value returned by L{acquireAttribute} is the value of the requested
        attribute on the first object in the list passed in which has that
        attribute.
        rPN�r�rPr!r�rrPrrr�test_foundOnEarlierObjectosz/AcquireAttributeTests.test_foundOnEarlierObjectcCs*t�|_}|�|tt�|gd�k�dS)z�
        The same as L{test_foundOnEarlierObject}, but for the case where the 2nd
        element in the object list has the attribute and the first does not.
        rPNr�r�rrr�test_foundOnLaterObjectysz-AcquireAttributeTests.test_foundOnLaterObjectcCs|�ttt�gd�dS)z�
        If none of the objects passed in the list to L{acquireAttribute} have
        the requested attribute, L{AttributeError} is raised.
        r>N)r��AttributeErrorrr�rArrr�test_notFoundException�sz,AcquireAttributeTests.test_notFoundExceptioncCs$t�}|�|tt�gd|�k�dS)z�
        If none of the objects passed in the list to L{acquireAttribute} have
        the requested attribute and a default value is given, the default value
        is returned.
        r>N)r�r!r)r�defaultrrr�test_notFoundDefault�sz*AcquireAttributeTests.test_notFoundDefaultN)r)r*r+r,r�r�r�r�rrrrr�ks

	r�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�ListToPhraseTestsz�
    Input is transformed into a string representation of the list,
    with each item separated by delimiter (defaulting to a comma) and the final
    two being separated by a final delimiter.
    cCs$g}d}t�|d�}|�||�dS)zB
        If things is empty, an empty string is returned.
        ��andN�r�
_listToPhraser�r�sampleZexpectedr1rrr�
test_empty�szListToPhraseTests.test_emptycCs&dg}d}t�|d�}|�||�dS)z;
        With a single item, the item is returned.
        �Oner�Nr�r�rrr�test_oneWord�szListToPhraseTests.test_oneWordcCs(ddg}d}t�|d�}|�||�dS)zA
        Two words are separated by the final delimiter.
        r��TwozOne and Twor�Nr�r�rrr�
test_twoWords�szListToPhraseTests.test_twoWordscCs*dddg}d}t�|d�}|�||�dS)zY
        With more than two words, the first two are separated by the delimiter.
        r�r��ThreezOne, Two, and Threer�Nr�r�rrr�test_threeWords�s
z!ListToPhraseTests.test_threeWordscCs0ddddg}d}tj|ddd�}|�||�d	S)
zW
        If a delimiter is specified, it is used instead of the default comma.
        r�r�r�ZFourzOne; Two; Three; or Four�orz; )Z	delimiterNr�r�rrr�test_fourWords�sz ListToPhraseTests.test_fourWordscCs*dddg}d}t�|d�}|�||�dS)zS
        If something in things is not a string, it is converted into one.
        rk�Zthreez1, 2, and threer�Nr�r�rrr�test_notString�s
z ListToPhraseTests.test_notStringcCs*d}|�ttj|d�}|�t|�d�dS)z?
        If things is a string, a TypeError is raised.
        zOne, two, threer�� Things must be a list or a tupleN�r��	TypeErrorrr�rr]�rr�r_rrr�test_stringTypeError�sz&ListToPhraseTests.test_stringTypeErrorcCs4tdddg�}|�ttj|d�}|�t|�d�dS)zB
        If things is an iterator, a TypeError is raised.
        rkr��r�r�N)�iterr�r�rr�rr]r�rrr�test_iteratorTypeError�sz(ListToPhraseTests.test_iteratorTypeErrorcCs.dd�}|�ttj|d�}|�t|�d�dS)zB
        If things is a generator, a TypeError is raised.
        csstd�D]
}|VqdS)Nr�)�range)�irrrr��sz9ListToPhraseTests.test_generatorTypeError.<locals>.sampler�r�Nr�r�rrr�test_generatorTypeError�sz)ListToPhraseTests.test_generatorTypeErrorN)
r)r*r+r,r�r�r�r�r�r�r�r�r�rrrrr��s





		r�)(r,Z
__future__rrrr�Zzope.interfacerZtwisted.python.compatrZtwisted.pythonrZtwisted.internet.interfacesrZtwisted.internetrZtwisted.internet.baser	Ztwisted.python.failurer
Ztwisted.trial.unittestrZ
twisted.trialrZtwisted.trial.utilr
rrrrr-r[r�rcrmrqr�r�r�r�rrrr�<module>s0+1/=U*