U
    
W[g  ã                   @   s:   d dl mZ d dlmZ d dlmZ G dd„ dejƒZdS )é    )Úunittest)Útext)Ú
attributesc                   @   sX   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ ZdS )ÚFormattedTextTestsz.
    Tests for assembling formatted text.
    c                 C   s   |   t tjd ¡d¡ dS )zu
        Using no formatting attributes produces no VT102 control sequences in
        the flattened output.
        úHello, world.N)ÚassertEqualr   ÚassembleFormattedTextÚAÚnormal©Úself© r   ú>/usr/lib/python3/dist-packages/twisted/conch/test/test_text.pyÚtest_trivial   s    þzFormattedTextTests.test_trivialc                 C   s   |   t tjd ¡d¡ dS )zƒ
        The bold formatting attribute, L{A.bold}, emits the VT102 control
        sequence to enable bold when flattened.
        r   z[1mHello, world.N)r   r   r   r	   Úboldr   r   r   r   Ú	test_bold   s    þzFormattedTextTests.test_boldc                 C   s   |   t tjd ¡d¡ dS )z”
        The underline formatting attribute, L{A.underline}, emits the VT102
        control sequence to enable underlining when flattened.
        r   z[4mHello, world.N)r   r   r   r	   Z	underliner   r   r   r   Útest_underline$   s    þz!FormattedTextTests.test_underlinec                 C   s   |   t tjd ¡d¡ dS )z‰
        The blink formatting attribute, L{A.blink}, emits the VT102 control
        sequence to enable blinking when flattened.
        r   z[5mHello, world.N)r   r   r   r	   Úblinkr   r   r   r   Ú
test_blink.   s    þzFormattedTextTests.test_blinkc                 C   s   |   t tjd ¡d¡ dS )zž
        The reverse-video formatting attribute, L{A.reverseVideo}, emits the
        VT102 control sequence to enable reversed video when flattened.
        r   z[7mHello, world.N)r   r   r   r	   ZreverseVideor   r   r   r   Útest_reverseVideo8   s    þz$FormattedTextTests.test_reverseVideoc              	   C   s0   |   t tjtjdtjd  df  ¡d¡ dS )zÉ
        Formatting attributes prefixed with a minus (C{-}) temporarily disable
        the prefixed attribute, emitting no VT102 control sequence to enable
        it in the flattened output.
        ZHelloz worldÚ.z[1;5mHello[0;5m world[1;5m.N)r   r   r   r	   r   r   r   r   r   r   Ú
test_minusB   s    ÿýzFormattedTextTests.test_minusc                 C   s0   |   t tjtjjd tjjd f ¡d¡ dS )z£
        The foreground color formatting attribute, L{A.fg}, emits the VT102
        control sequence to set the selected foreground color when flattened.
        úHello, úworld!z[31mHello, [32mworld!N)r   r   r   r	   r
   ZfgÚredÚgreenr   r   r   r   Útest_foregroundN   s    ÿýz"FormattedTextTests.test_foregroundc                 C   s0   |   t tjtjjd tjjd f ¡d¡ dS )z£
        The background color formatting attribute, L{A.bg}, emits the VT102
        control sequence to set the selected background color when flattened.
        r   r   z[41mHello, [42mworld!N)r   r   r   r	   r
   Zbgr   r   r   r   r   r   Útest_backgroundY   s    ÿýz"FormattedTextTests.test_backgroundc                 C   sn   |   | jg¡}|  t|ƒd¡ tj |   | jg¡}|  t|ƒd¡ |  |d d t¡ |  |d d d¡ dS )zv
        L{twisted.conch.insults.text.flatten} emits a deprecation warning when
        imported or accessed.
        r   é   ÚcategoryÚmessagez‚twisted.conch.insults.text.flatten was deprecated in Twisted 13.1.0: Use twisted.conch.insults.text.assembleFormattedText instead.N)ZflushWarningsÚtest_flattenDeprecatedr   Úlenr   ZflattenÚDeprecationWarning)r   ZwarningsShownr   r   r   r!   d   s    
þz)FormattedTextTests.test_flattenDeprecatedN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r!   r   r   r   r   r      s   




r   N)	Ztwisted.trialr   Ztwisted.conch.insultsr   Ztwisted.conch.insults.textr   r	   ZTestCaser   r   r   r   r   Ú<module>   s   