관리-도구
편집 파일: test_formatparagraph.cpython-35.opt-2.pyc
���]�7 � @ s4 d d l Z d d l m Z d d l m Z d d l m Z m Z d d l m Z Gd d � d e j � Z Gd d � d e j � Z Gd d � d e j � Z Gd d � d e j � Z Gd d � d e j � Z Gd d � d � Z Gd d � d � Z Gd d � d e j � Z e d k r0e j d d d d � d S)� N)�FormatParagraph)�EditorWindow)�Tk�Text)�requiresc @ sR e Z d Z d Z d Z d Z d Z d Z d d � Z d d � Z d d � Z d S) �Is_Get_Testz# This is a commentzThis is not a commentz# This is a comment z # This is a commentz This is not a commentc C sI | j t j d � � | j t j d � � | j t j | j � � d S)N� z )Z assertTrue�fpZis_all_whiteZassertFalse�test_comment)�self� r �9/opt/alt/python35/lib64/python3.5/test_formatparagraph.py�test_is_all_white s zIs_Get_Test.test_is_all_whitec C sq | j } | t j | j � d � | t j | j � d � | t j | j � d � | t j | j � d � d S)Nr z )�assertEqualr Z get_indentr �trailingws_comment�leadingws_comment�leadingws_nocomment)r �Equalr r r �test_get_indent s zIs_Get_Test.test_get_indentc C s� | j } | t j | j � d � | t j | j � d � | t j | j � d � | t j | j � d � | t j | j � d � d S)N�#z #z r )r r Zget_comment_headerr r r r �test_nocomment)r r r r r �test_get_comment_header s z#Is_Get_Test.test_get_comment_headerN)�__name__� __module__�__qualname__r r r r r r r r r r r r r s r c @ sF e Z d Z e d d � � Z d d � Z d d � Z d d � Z d S) �FindTestc C s d d l m } | � | _ d S)Nr )r )Zidlelib.idle_test.mock_tkr �text)�clsr r r r � setUpClass2 s zFindTest.setUpClassc C s� | j } | j d | � x� t d | � D]v } t | j d | � j d � d � } xG d | d | f D]2 } d | | f } | j t j | | � | � qi Wq) W| j d d � d S) Nz1.0� z%d.end�.r � z%d.%d�end) r �insert�range�int�index�splitr r Zfind_paragraph�delete) r Z inserttextZstopline�expectedr �lineZ linelength�colZ tempindexr r r �runcase7 s &$zFindTest.runcasec C s| d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d S)Nz;# Comment block with no blank lines before # Comment line � z1.0z3.0r r �: zG # Comment block with whitespace line before and after # Comment line � z2.0z4.0r �F zS # Indented comment block with whitespace before and after # Comment line z #�R z # Single line comment � z4 # Single line comment with leading whitespace �3 z0 # Comment immediately followed by code x = 42 �( z= # Indented comment immediately followed by code x = 42 �5 z= # Comment immediately followed by indented code x = 42 �1 )r, )r Zcommentr r r �test_find_commentD s )))))))zFindTest.test_find_commentc C s� d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d } | j | d d d d | d d � f � d S)Nz6"""String with no blank lines before String line """ r/ z1.0z4.0r r r5 zC """String with whitespace line before and after String line. """ � z2.0z5.0r �B zV """Indented string with whitespace before and after Comment string. """ z �U z """Single line string.""" r- z3.0� z8 """Single line string with leading whitespace.""" �7 )r, )r Z teststringr r r �test_find_paragraphz s ))))zFindTest.test_find_paragraphN)r r r �classmethodr r, r7 r= r r r r r ( s 6r c @ s e Z d Z d d � Z d S)�ReformatFunctionTestc C s* | j } t j } d } | | d d � d � | | d d � d � | | | d � d � | | | d � d � | | | d � d � | | | d � d � | | | d � d � d } | | | d � d � | | | d � d � | | | d � d � | | | d � d � | | | d � d � d S)Nz O hello world� r zHello world� zHello worldz O hello world� � z O hello world� � z O hello worldz O hello worldz O hello world)r r Zreformat_paragraph)r r ZreformZhwr r r �test_reformat_paragraph� s z,ReformatFunctionTest.test_reformat_paragraphN)r r r rF r r r r r? � s r? c @ s e Z d Z d d � Z d S)�ReformatCommentTestc C si | j } d } t j | d d � } d } | | | � d } t j | d d � } d } | | | � d S)Nzu """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""r0 z zy """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""zm# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?r zo# this is a test of a reformat for a triple quoted string will it # reformat to less than 70 characters for me?)r r Zreformat_comment)r r �test_string�resultr) r r r r �test_reformat_comment� s z)ReformatCommentTest.test_reformat_commentN)r r r rJ r r r r rG � s rG c @ s e Z d Z d d � Z d S)�FormatClassTestc C sC t j d � } | j | j d � | j � | j | j d � d S)N�editor)r r r Zeditwin�close)r �instancer r r �test_init_close� s zFormatClassTest.test_init_closeN)r r r rO r r r r rK � s rK c @ s@ e Z d Z d d � Z d d � Z d d � Z d d � Z d S) �TextWrapperc C s t d | � | _ d S)N�master)r r )r rQ r r r �__init__� s zTextWrapper.__init__c C s t | j | � S)N)�getattrr )r �namer r r �__getattr__� s zTextWrapper.__getattr__c C s d S)Nr )r r r r �undo_block_start� s zTextWrapper.undo_block_startc C s d S)Nr )r r r r �undo_block_stop� s zTextWrapper.undo_block_stopN)r r r rR rU rV rW r r r r rP � s rP c @ s% e Z d Z d d � Z e j Z d S)�Editorc C s t | � | _ d S)N)rP r )r �rootr r r rR � s zEditor.__init__N)r r r rR r Zget_selection_indicesr r r r rX � s rX c @ sv e Z d Z d Z d Z d Z e d d � � Z e d d � � Z d d � Z d d � Z d d � Z d d � Z d S)�FormatEventTestzv '''this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?''' a '''The first line is under the max width. The second line's length is way over the max width. It goes on and on until it is over 100 characters long. Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. ''' a, # The first line is under the max width. # The second line's length is way over the max width. It goes on and on until it is over 100 characters long. # Same thing with the third line. It is also way over the max width, but FormatParagraph will fix it. # The fourth line is short like the first line.c C sP t d � t � | _ t d | j � } | j j | _ t j | � j | _ d S)NZguirY ) r r rY rX r r r Zformat_paragraph_event� formatter)r rL r r r r s zFormatEventTest.setUpClassc C s# | ` | ` | j j � | ` d S)N)r r[ rY Zdestroy)r r r r � tearDownClass s zFormatEventTest.tearDownClassc C sV | j j d d � | j d � | j | j j d d � d � | j j d d � d S)Nz1.0zShort line ZDummyr# r"