관리-도구
편집 파일: test_paragraph.cpython-36.opt-2.pyc
3 ��2a8 � @ s� d dl mZ d dlZd dlmZ d dlmZmZ d dl m Z G dd� dej�ZG dd � d ej�Z G d d� dej�ZG dd � d ej�ZG dd� dej�ZG dd� d�ZG dd� d�ZG dd� dej�Zedkr�ejddd� dS )� )� paragraphN)�requires)�Tk�Text)�EditorWindowc @ s8 e Zd ZdZdZdZdZdZdd� Zdd � Z d d� Z dS ) �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 s6 | j tjd�� | j tjd�� | jtj| j�� d S )N� z )Z assertTrue�pgZis_all_whiteZassertFalse�test_comment)�self� r �3/opt/alt/python36/lib64/python3.6/test_paragraph.py�test_is_all_white s zIs_Get_Test.test_is_all_whitec C sR | j }|tj| j�d� |tj| j�d� |tj| j�d� |tj| 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 sd | j }|tj| j�d� |tj| j�d� |tj| j�d� |tj| j�d� |tj| 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 @ s0 e Zd Zedd� �Zdd� Zdd� Zdd� Zd S ) �FindTestc C s ddl m} |� | _d S )Nr )r )Zidlelib.idle_test.mock_tkr �text)�clsr r r r � setUpClass3 s zFindTest.setUpClassc C s� | j }|jd|� xftd|�D ]X}t|jd| �jd�d �}x6d|d |fD ]$}d||f }| jtj||�|� qNW qW |j dd� 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 �runcase8 s zFindTest.runcasec C s d}| j |dddd|dd� f� d}| j |d d dd|dd � f� d}| j |d d dd|dd� f� d}| j |dd dd|dd� f� d}| j |dd dd|dd� f� d}| j |dd dd|dd� f� d}| j |dd dd|dd� f� d}| j |dd dd|dd� 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_commentE s zFindTest.test_find_commentc C s� d}| j |dddd|dd� f� d}| j |d d dd|dd � f� d}| j |d d dd|dd� f� d}| j |dd dd|dd� f� d}| j |dd dd|dd� 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_paragraph{ s zFindTest.test_find_paragraphN)r r r �classmethodr r, r7 r= r r r r r ) s 6r c @ s e Zd Zdd� ZdS )�ReformatFunctionTestc C s� | j }tj}d}||dd�d� ||dd�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 Zd Zdd� ZdS )�ReformatCommentTestc C sJ | j }d}tj|dd�}d}|||� d}tj|dd�}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 Zd Zdd� ZdS )�FormatClassTestc C s2 t jd�}| j|jd� |j� | j|jd � d S )N�editor)r �FormatParagraphr Zeditwin�close)r �instancer r r �test_init_close� s zFormatClassTest.test_init_closeN)r r r rP r r r r rK � s rK c @ s, e Zd Zdd� Zdd� Zdd� Zdd� Zd S ) �TextWrapperc C s t |d�| _d S )N)�master)r r )r rR 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 rS rV rW rX r r r r rQ � s rQ c @ s e Zd Zdd� ZejZdS )�Editorc C s t |�| _d S )N)rQ r )r �rootr r r rS � s zEditor.__init__N)r r r rS r Zget_selection_indicesr r r r rY � s rY c @ sP e Zd ZdZdZdZedd� �Zedd� �Zdd � Z d d� Z dd � Zdd� ZdS )�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 sB t d� t� | _| jj� t| jd�}|jj| _tj|�j| _ d S )NZgui)rZ ) r r rZ ZwithdrawrY r r rM Zformat_paragraph_event� formatter)r rL r r r r s zFormatEventTest.setUpClassc C s$ | ` | `| jj� | jj� | `d S )N)r r\ rZ Zupdate_idletasksZdestroy)r r r r � tearDownClass s zFormatEventTest.tearDownClassc C s@ | j jdd� | jd� | j| j jdd�d� | j jdd� d S )Nz1.0zShort line ZDummyr# r"