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" )r r# r\ r Úgetr( )r r r r
Útest_short_line s
zFormatEventTest.test_short_linec C s¬ | j }|jd| jƒ |jddƒ | jddd� |jddƒ}d}| j||ƒ |jddƒ |jd| jƒ |jdd d
ƒ | jddd� |jddƒ}d}| j||ƒ |jddƒ d S )Nz1.0r# ÚParameterDoesNothingr0 )Úlimitzz '''this is a test of a reformat for a triple quoted string will it
reformat to less than 70 characters for me?'''
r" Úselz1.11z1.endzv '''this is a test of a reformat for a triple quoted string will it reformat
to less than 70 characters for me?''') r r# rH Zmark_setr\ r^ r r( Útag_add)r r rI r) r r r
Útest_long_line$ s zFormatEventTest.test_long_linec C s\ | j }|jd| jƒ |jdddƒ | jddd� |jddƒ}d }| j||ƒ |jdd
ƒ d S )Nz1.0rb z2.0z4.0r` r0 )ra r# zà 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.
r" )r r# Úmultiline_test_stringrc r\ r^ r r( )r r rI r) r r r
Útest_multiple_lines? s z#FormatEventTest.test_multiple_linesc C s | j }|jd| jƒ | jddd� |jddƒ}d}| j||ƒ |jddƒ |jd| jƒ |jdd d
ƒ | jddd� |jddƒ}d}| j||ƒ |jddƒ d S )Nz1.0r` r0 )ra r# 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.
r" rb z2.0z3.0z™# 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.
)r r# Úmultiline_test_commentr\ r^ r r( rc )r r rI r) r r r
Útest_comment_blockN s z"FormatEventTest.test_comment_blockN)
r r r rH re rg r> r r] r_ rd rf rh r r r r
r[ ô s
r[ Ú__main__r! )Ú verbosityÚexit)Zidlelibr r ZunittestZtest.supportr Ztkinterr r Zidlelib.editorr ZTestCaser r r? rG rK rQ rY r[ r Úmainr r r r
Ú