й¼]û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" )r r# r[ r Úgetr( )r r r r
Útest_short_line s
zFormatEventTest.test_short_linec C sì | j } | j d | j ƒ | j d d ƒ | j d d d ƒ| j d d ƒ } d } | j | | ƒ | j d d ƒ | j d | j ƒ | j d d d
ƒ | j d d d ƒ| j d d ƒ } d } | j | | ƒ | j d d ƒ d S)Nz1.0r# ÚParameterDoesNothingÚlimitr0 zz '''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 } | j d | j ƒ | j d d d ƒ | j d d d ƒ| j d d ƒ } d } | j | | ƒ | j d d
ƒ d S)Nz1.0ra z2.0z4.0r_ r` r0 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_stringrb r[ r] r r( )r r rI r) r r r
Útest_multiple_lines< s z#FormatEventTest.test_multiple_linesc C sÜ | j } | j d | j ƒ | j d d d ƒ| j d d ƒ } d } | j | | ƒ | j d d ƒ | j d | j ƒ | j d d d
ƒ | j d d d ƒ| j d d ƒ } d } | j | | ƒ | j d d ƒ d S)Nz1.0r_ r` r0 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" ra 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( rb )r r rI r) r r r
Útest_comment_blockK s z"FormatEventTest.test_comment_blockN)
r r r rH rd rf r> r r\ r^ rc re rg r r r r
rZ ó s rZ Ú__main__Ú verbosityr! Úexit)ZunittestZidlelibr r Zidlelib.EditorWindowr Útkinterr r Ztest.supportr ZTestCaser r r? rG rK rP rX rZ r Úmainr r r r
Ú