
    \d                         d Z ddlmZ ddlmZ ddlmZ dZ G d dej                  Z	 G d d	ej                  Z
 G d
 dej                  Z G d dej                  Z G d dej                  ZdS )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                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )	WrapTestsz'
    Tests for L{text.greedyWrap}.
    c                     d| _         t                                          | _        t	          j        t          | j                   | _        d S )NH   )	lineWidth
sampleTextsplitsampleSplitTextr   wordWrapoutputselfs    6lib/python3.11/site-packages/twisted/test/test_text.pysetUpzWrapTests.setUp   s6    )//11mJ??    c                     g }| j         D ])}|                    |                                           *t          |          }t          | j                  }|                     ||           dS )z.
        Compare the number of words.
        N)r   extendr   lenr   assertEqual)r   wordsline	wordCountsampleTextWordCounts        r   test_wordCountzWrapTests.test_wordCount"   sp     K 	' 	'DLL&&&&JJ	!$"677$788888r   c                     g }| j         D ])}|                    |                                           *|                     | j        |k               dS )z-
        Compare the lists of words.
        N)r   r   r   
assertTruer   )r   r   r   s      r   test_wordMatchzWrapTests.test_wordMatch.   sY     K 	' 	'DLL&&&& 	,566666r   c                    g }| j         D ]<}t          |          | j        k    s"|                    t          |                     =|rB|                     dt          |          t          | j                   | j        |fz             dS dS )z0
        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_lineLengthzWrapTests.test_lineLength:   s     K 	+ 	+Dt99..D		*** 	II ]]C,<,<dnhWX    	 	r   c                 n    d}t          j        || j                  }|                     |g d           dS )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_doubleNewlinezWrapTests.test_doubleNewlineI   s?     *
z4>::!>!>!>?????r   N)	__name__
__module____qualname____doc__r   r   r    r%   r*    r   r   r   r      sq         @ @ @

9 
9 
9
7 
7 
7  @ @ @ @ @r   r   c                       e Zd ZdZd Zd ZdS )	LineTestsz8
    Tests for L{isMultiline} and L{endsInNewline}.
    c                     d}t          j        |          }|                     |           d}t          j        |          }|                     |           dS )zX
        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_isMultilinezLineTests.test_isMultilineW   sZ     $Q)Qr   c                     d}t          j        |          }|                     |           d}t          j        |          }|                     |           dS )zX
        L{text.endsInNewline} returns C{True} if the string ends in a newline.
        znewline
oldlineN)r   endsInNewliner   r4   r5   s      r   test_endsInNewlinezLineTests.test_endsInNewlinec   sZ     q!!q!!r   N)r+   r,   r-   r.   r8   r<   r/   r   r   r1   r1   R   s<         
 
 

 
 
 
 
r   r1   c                   $    e Zd ZdZd Zd Zd ZdS )StringyStringTestsz*
    Tests for L{text.stringyString}.
    c                 ^    d}t          j        |          }|                     |d           dS )zA
        Tuple elements are displayed on separate lines.
        )abz	(a,
 b,)
Nr   stringyStringr   r5   s      r   
test_tuplezStringyStringTests.test_tupleu   s5     q!!M*****r   c                 b    ddi}t          j        |          }|                     |d           dS )z>
        Dicts elements are displayed using C{str()}.
        r@   r   z{a: 0}NrB   r5   s      r   	test_dictzStringyStringTests.test_dict}   s9     !Hq!!H%%%%%r   c                 b    ddg}t          j        |          }|                     |d           dS )zO
        List elements are displayed on separate lines using C{str()}.
        r@   rA   z	[a,
 b,]
NrB   r5   s      r   	test_listzStringyStringTests.test_list   s9     #Jq!!M*****r   N)r+   r,   r-   r.   rD   rF   rH   r/   r   r   r>   r>   p   sK         + + +& & &+ + + + +r   r>   c                       e Zd ZdZd Zd ZdS )
SplitTestsz(
    Tests for L{text.splitQuoted}.
    c                 b    d}t          j        |          }|                     g d|           dS )z:
        Splitting strings with one-word phrases.
        zThis code "works.")Thiscodezworks.Nr   splitQuotedr   r   r6   rs      r   test_oneWordzSplitTests.test_oneWord   s<     !Q333Q77777r   c                 b    d}t          j        |          }|                     g d|           d S )NzThe "hairy monkey" likes pie.)Thezhairy monkeylikeszpie.rN   rP   s      r   test_multiWordzSplitTests.test_multiWord   s:    +QAAA1EEEEEr   N)r+   r,   r-   r.   rR   rV   r/   r   r   rJ   rJ      sA         8 8 8F F F F Fr   rJ   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )StrFileTestsc                 .    t          d          | _        d S Nzthis is a test string)r   ior   s    r   r   zStrFileTests.setUp   s    233r   c                     d S )Nr/   r   s    r   tearDownzStrFileTests.tearDown   s    r   c                 `    |                      t          j        d| j                             d S )Nxr4   r   strFiler[   r   s    r   test_1_fzStrFileTests.test_1_f   s*    c473344444r   c                 `    |                      t          j        d| j                             d S )Ntr   r   ra   r[   r   s    r   test_1_1zStrFileTests.test_1_1   (    S$'2233333r   c                 `    |                      t          j        d| j                             d S )Nhre   r   s    r   test_1_2zStrFileTests.test_1_2   rg   r   c                 `    |                      t          j        d| j                             d S )Nire   r   s    r   test_1_3zStrFileTests.test_1_3   rg   r   c                 `    |                      t          j        d| j                             d S )Nr6   re   r   s    r   test_1_4zStrFileTests.test_1_4   rg   r   c                 `    |                      t          j        d| j                             d S )Nnre   r   s    r   test_1_5zStrFileTests.test_1_5   rg   r   c                 `    |                      t          j        d| j                             d S )Ngre   r   s    r   test_1_6zStrFileTests.test_1_6   rg   r   c                 `    |                      t          j        d| j                             d S )Nthire   r   s    r   test_3_1zStrFileTests.test_3_1   (    UDG4455555r   c                 `    |                      t          j        d| j                             d S )Nhisre   r   s    r   test_3_2zStrFileTests.test_3_2   ry   r   c                 `    |                      t          j        d| j                             d S )Nzis re   r   s    r   test_3_3zStrFileTests.test_3_3   ry   r   c                 `    |                      t          j        d| j                             d S )Ningre   r   s    r   test_3_4zStrFileTests.test_3_4   ry   r   c                 `    |                      t          j        d| j                             d S )Nblar`   r   s    r   test_3_fzStrFileTests.test_3_f   s*    eTW5566666r   c                 `    |                      t          j        d| j                             d S )Nzthis is a testre   r   s    r   test_large_1zStrFileTests.test_large_1   s)    %5tw??@@@@@r   c                 `    |                      t          j        d| j                             d S )Nzis a test stringre   r   s    r   test_large_2zStrFileTests.test_large_2   s)    %7AABBBBBr   c                 `    |                      t          j        d| j                             d S )Nzds jhfsa k fdasr`   r   s    r   test_large_fzStrFileTests.test_large_f   s+    &7AABBBBBr   c                 `    |                      t          j        d| j                             d S )Nz-djhsakj dhsa fkhsa s,mdbnfsauiw bndasdf hreewr`   r   s    r   test_overlarge_fzStrFileTests.test_overlarge_f   s6    LH$'RR	
 	
 	
 	
 	
r   c                 `    |                      t          j        d| j                             d S rZ   re   r   s    r   	test_selfzStrFileTests.test_self   s)    %<dgFFGGGGGr   c                 b    |                      t          j        d| j        d                     d S )NzThIs is A test STRINGFre   r   s    r   test_insensitivezStrFileTests.test_insensitive   s+    %<dguMMNNNNNr   N)r+   r,   r-   r   r]   rb   rf   rj   rm   ro   rr   ru   rx   r|   r~   r   r   r   r   r   r   r   r   r/   r   r   rX   rX      sQ       4 4 4  5 5 54 4 44 4 44 4 44 4 44 4 44 4 46 6 66 6 66 6 66 6 67 7 7A A AC C CC C C
 
 

H H HO O O O Or   rX   N)r.   r[   r   twisted.pythonr   twisted.trialr   r   TestCaser   r1   r>   rJ   rX   r/   r   r   <module>r      sU                " " " " " "
7@ 7@ 7@ 7@ 7@! 7@ 7@ 7@t    !   <+ + + + +* + + +<F F F F F" F F F@=O =O =O =O =O8$ =O =O =O =O =Or   