本文整理汇总了Python中idlelib.FormatParagraph类的典型用法代码示例。如果您正苦于以下问题:Python FormatParagraph类的具体用法?Python FormatParagraph怎么用?Python FormatParagraph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FormatParagraph类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_comment_header
def test_get_comment_header(self):
Equal = self.assertEqual
Equal(fp.get_comment_header(self.test_comment), '#')
Equal(fp.get_comment_header(self.trailingws_comment), '#')
Equal(fp.get_comment_header(self.leadingws_comment), ' #')
Equal(fp.get_comment_header(self.leadingws_nocomment), ' ')
Equal(fp.get_comment_header(self.test_nocomment), '')
示例2: test_reformat_comment
def test_reformat_comment(self):
Equal = self.assertEqual
test_string = ' """this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?"""'
result = fp.reformat_comment(test_string, 70, ' ')
expected = ' """this is a test of a reformat for a triple quoted string will it\n reformat to less than 70 characters for me?"""'
Equal(result, expected)
test_comment = '# this is a test of a reformat for a triple quoted string will it reformat to less than 70 characters for me?'
result = fp.reformat_comment(test_comment, 70, '#')
expected = '# this is a test of a reformat for a triple quoted string will it\n# reformat to less than 70 characters for me?'
Equal(result, expected)
示例3: runcase
def runcase(self, inserttext, stopline, expected):
text = self.text
text.insert('1.0', inserttext)
for line in range(1, stopline):
linelength = int(text.index('%d.end' % line).split('.')[1])
for col in (0, linelength // 2, linelength):
tempindex = '%d.%d' % (line, col)
self.assertEqual(fp.find_paragraph(text, tempindex), expected)
text.delete('1.0', 'end')
示例4: runcase
def runcase(self, inserttext, stopline, expected):
# Check that find_paragraph returns the expected paragraph when
# the mark index is set to beginning, middle, end of each line
# up to but not including the stop line
text = self.text
text.insert('1.0', inserttext)
for line in range(1, stopline):
linelength = int(text.index("%d.end" % line).split('.')[1])
for col in (0, linelength//2, linelength):
tempindex = "%d.%d" % (line, col)
self.assertEqual(fp.find_paragraph(text, tempindex), expected)
text.delete('1.0', 'end')
示例5: test_reformat_comment
def test_reformat_comment(self):
Equal = self.assertEqual
# reformat_comment formats to a minimum of 20 characters
test_string = (
" \"\"\"this is a test of a reformat for a triple quoted string"
" will it reformat to less than 70 characters for me?\"\"\"")
result = fp.reformat_comment(test_string, 70, " ")
expected = (
" \"\"\"this is a test of a reformat for a triple quoted string will it\n"
" reformat to less than 70 characters for me?\"\"\"")
Equal(result, expected)
test_comment = (
"# this is a test of a reformat for a triple quoted string will "
"it reformat to less than 70 characters for me?")
result = fp.reformat_comment(test_comment, 70, "#")
expected = (
"# this is a test of a reformat for a triple quoted string will it\n"
"# reformat to less than 70 characters for me?")
Equal(result, expected)
示例6: test_is_all_white
def test_is_all_white(self):
self.assertTrue(fp.is_all_white(''))
self.assertTrue(fp.is_all_white('\t\n\r\x0c\x0b'))
self.assertFalse(fp.is_all_white(self.test_comment))