
    h                        S r SSKJr  SSKJr  SSKJr  Sr " S S\R                  5      r	 " S S	\R                  5      r
 " S
 S\R                  5      r " S S\R                  5      r " S S\R                  5      rg)z#
Tests for L{twisted.python.text}.
    )StringIO)text)unittesta  Every attempt to employ mathematical methods in the study of chemical
questions must be considered profoundly irrational and contrary to the
spirit of chemistry ...  If mathematical analysis should ever hold a
prominent place in chemistry - an aberration which is happily almost
impossible - it would occasion a rapid and widespread degeneration of that
science.

           --  Auguste Comte, Philosophie Positive, Paris, 1838
c                   J    \ rS rSrSrS
S jrS
S jrS
S jrS
S jrS
S jr	S	r
g)	WrapTests   z
Tests for L{text.greedyWrap}.
Nc                     SU l         [        R                  5       U l        [        R
                  " [        U R                   5      U l        g )NH   )	lineWidth
sampleTextsplitsampleSplitTextr   wordWrapoutputselfs    ]/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/test/test_text.pysetUpWrapTests.setUp   s0    )//1mmJ?    c                     / nU R                    H"  nUR                  UR                  5       5        M$     [        U5      n[        U R                  5      nU R                  X45        g)z
Compare the number of words.
N)r   extendr   lenr   assertEqual)r   wordsline	wordCountsampleTextWordCounts        r   test_wordCountWrapTests.test_wordCount"   sQ     KKDLL&  J	!$"6"678r   c                     / nU R                    H"  nUR                  UR                  5       5        M$     U R                  U R                  U:H  5        g)z
Compare the lists of words.
N)r   r   r   
assertTruer   )r   r   r   s      r   test_wordMatchWrapTests.test_wordMatch.   sB     KKDLL&  
 	,,56r   c                 $   / nU R                    H8  n[        U5      U R                  ::  a  M  UR                  [        U5      5        M:     U(       a?  U R	                  S[        U5      [        U R                   5      U R                  U4-  5        gg)z 
Check the length of the lines.
z%%d of %d lines were too long.
%d < %sN)r   r   r   appendfail)r   failuresr   s      r   test_lineLengthWrapTests.test_lineLength:   su     KKDt9.D	*   II ]C,<dnnhWX r   c                 p    Sn[         R                  " XR                  5      nU R                  U/ SQ5        g)z7
        Allow paragraphs delimited by two 
s.
        zet

phone
home.)et zphone home.r-   N)r   r   r   r   )r   r   results      r   test_doubleNewlineWrapTests.test_doubleNewlineI   s,     *
z>>:!>?r   )r   r   r   returnN)__name__
__module____qualname____firstlineno____doc__r   r   r#   r)   r/   __static_attributes__ r   r   r   r      s"    @

9
7@r   r   c                   ,    \ rS rSrSrSS jrSS jrSrg)	LineTestsR   z0
Tests for L{isMultiline} and L{endsInNewline}.
Nc                     Sn[         R                  " U5      nU R                  U5        Sn[         R                  " U5      nU R                  U5        g)zH
L{text.isMultiline} returns C{True} if the string has a newline in it.
zThis code
 "breaks."zThis code does not "break."N)r   isMultiliner"   assertFalser   sms      r   test_isMultilineLineTests.test_isMultilineW   sH     $Q)Qr   c                     Sn[         R                  " U5      nU R                  U5        Sn[         R                  " U5      nU R                  U5        g)zH
L{text.endsInNewline} returns C{True} if the string ends in a newline.
znewline
oldlineN)r   endsInNewliner"   r?   r@   s      r   test_endsInNewlineLineTests.test_endsInNewlinec   sH     q!q!r   r9   r1   )r3   r4   r5   r6   r7   rC   rH   r8   r9   r   r   r;   r;   R   s    

r   r;   c                   6    \ rS rSrSrSS jrSS jrSS jrSrg)	StringyStringTestsp   z"
Tests for L{text.stringyString}.
Nc                 X    Sn[         R                  " U5      nU R                  US5        g)z1
Tuple elements are displayed on separate lines.
)abz	(a,
 b,)
Nr   stringyStringr   r@   s      r   
test_tupleStringyStringTests.test_tupleu   s)     q!M*r   c                 \    SS0n[         R                  " U5      nU R                  US5        g)z.
Dicts elements are displayed using C{str()}.
rN   r   z{a: 0}NrP   r@   s      r   	test_dictStringyStringTests.test_dict}   s-     !Hq!H%r   c                 \    SS/n[         R                  " U5      nU R                  US5        g)z?
List elements are displayed on separate lines using C{str()}.
rN   rO   z	[a,
 b,]
NrP   r@   s      r   	test_listStringyStringTests.test_list   s-     #Jq!M*r   r9   r1   )	r3   r4   r5   r6   r7   rR   rU   rX   r8   r9   r   r   rK   rK   p   s    +&+r   rK   c                   ,    \ rS rSrSrSS jrSS jrSrg)
SplitTests   z 
Tests for L{text.splitQuoted}.
Nc                 \    Sn[         R                  " U5      nU R                  / SQU5        g)z*
Splitting strings with one-word phrases.
zThis code "works.")Thiscodezworks.Nr   splitQuotedr   r   rA   rs      r   test_oneWordSplitTests.test_oneWord   s*     !Q3Q7r   c                 \    Sn[         R                  " U5      nU R                  / SQU5        g )NzThe "hairy monkey" likes pie.)Thezhairy monkeylikeszpie.r`   rb   s      r   test_multiWordSplitTests.test_multiWord   s(    +QA1Er   r9   r1   )r3   r4   r5   r6   r7   rd   ri   r8   r9   r   r   r[   r[      s    8Fr   r[   c                       \ rS rSrSS jrSS jrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSS jrSrg)StrFileTests   Nc                 $    [        S5      U l        g Nzthis is a test string)r   ior   s    r   r   StrFileTests.setUp   s    23r   c                     g )Nr9   r   s    r   tearDownStrFileTests.tearDown   s    r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nxr?   r   strFilerp   r   s    r   test_1_fStrFileTests.test_1_f   s    c47734r   c                 d    U R                  [        R                  " SU R                  5      5        g )Ntr"   r   rx   rp   r   s    r   test_1_1StrFileTests.test_1_1       S$''23r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nhr}   r   s    r   test_1_2StrFileTests.test_1_2   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nir}   r   s    r   test_1_3StrFileTests.test_1_3   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )NrA   r}   r   s    r   test_1_4StrFileTests.test_1_4   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nnr}   r   s    r   test_1_5StrFileTests.test_1_5   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )Ngr}   r   s    r   test_1_6StrFileTests.test_1_6   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nthir}   r   s    r   test_3_1StrFileTests.test_3_1       UDGG45r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nhisr}   r   s    r   test_3_2StrFileTests.test_3_2   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nzis r}   r   s    r   test_3_3StrFileTests.test_3_3   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )Ningr}   r   s    r   test_3_4StrFileTests.test_3_4   r   r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nblarw   r   s    r   test_3_fStrFileTests.test_3_f   s    eTWW56r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nzthis is a testr}   r   s    r   test_large_1StrFileTests.test_large_1   s    %5tww?@r   c                 d    U R                  [        R                  " SU R                  5      5        g )Nzis a test stringr}   r   s    r   test_large_2StrFileTests.test_large_2   s    %7ABr   c                 d    U R                  [        R                  " SU R                  5      5        g )Nzds jhfsa k fdasrw   r   s    r   test_large_fStrFileTests.test_large_f   s     &7ABr   c                 d    U R                  [        R                  " SU R                  5      5        g )Nz-djhsakj dhsa fkhsa s,mdbnfsauiw bndasdf hreewrw   r   s    r   test_overlarge_fStrFileTests.test_overlarge_f   s#    LLH$''R	
r   c                 d    U R                  [        R                  " SU R                  5      5        g ro   r}   r   s    r   	test_selfStrFileTests.test_self   s    %<dggFGr   c                 f    U R                  [        R                  " SU R                  S5      5        g )NzThIs is A test STRINGFr}   r   s    r   test_insensitiveStrFileTests.test_insensitive   s     %<dgguMNr   )rp   r1   )r3   r4   r5   r6   r   rs   ry   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r8   r9   r   r   rl   rl      sk    4544444466667ACC

HOr   rl   N)r7   rp   r   twisted.pythonr   twisted.trialr   r   TestCaser   r;   rK   r[   rl   r9   r   r   <module>r      s~      "
7@!! 7@t!! <+** +<F"" F@=O8$$ =Or   