Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6f36b68
Edit help_about and test_help_about.
terryjreedy Jun 17, 2018
52a3636
Edit test_history.
terryjreedy Jun 17, 2018
3d19927
Edit hyperparser and test_hyperparser.
terryjreedy Jun 17, 2018
89acd39
Re-add template.py.
terryjreedy Jun 17, 2018
ce297a0
Edit test_run, adding pseudofile tests from test_iomenu.
terryjreedy Jun 17, 2018
8e87ce9
Merge remote-tracking branch 'origin/master' into moretest2
terryjreedy Jun 17, 2018
5fb8d55
Edit iomenu and replace tests mover to test_run with io init.
terryjreedy Jun 17, 2018
ccfe37f
Edit test_macosx.
terryjreedy Jun 17, 2018
16f8d94
Edit mainmenu and add test_mainmenu.
terryjreedy Jun 17, 2018
d66338a
Edit multicall and add test_multicall.
terryjreedy Jun 17, 2018
483ac25
Edit test_outwin.
terryjreedy Jun 17, 2018
affce4a
Edit paragraph and test_paragraph.
terryjreedy Jun 17, 2018
84b8d7d
whitespace
terryjreedy Jun 17, 2018
e48da3b
Edit test_pathbrowser.
terryjreedy Jun 18, 2018
7fb1ffb
Edit parenmatch and test_parenmatch.
terryjreedy Jun 18, 2018
d5254ce
Edit percolator and test_percolator.
terryjreedy Jun 18, 2018
f2651b6
Edit pyparse and test_pyparse.
terryjreedy Jun 18, 2018
442347e
Add test_pyshell.
terryjreedy Jun 18, 2018
cd35b55
Edit query and test_query.
terryjreedy Jun 18, 2018
4bef8d6
Correct tes_query coverage.
terryjreedy Jun 18, 2018
f52bb2e
Whitespace.
terryjreedy Jun 18, 2018
6e9c4a9
Edit redirector and test_redirector.
terryjreedy Jun 18, 2018
1195a35
Edit replace and test_replace.
terryjreedy Jun 18, 2018
5e01046
Add coverage.
terryjreedy Jun 18, 2018
411e6b3
Update test_mainmenu.py
terryjreedy Jun 18, 2018
d0fef08
Update test_query.py
terryjreedy Jun 18, 2018
2f22ed4
Update test_replace.py
terryjreedy Jun 18, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Edit paragraph and test_paragraph.
  • Loading branch information
terryjreedy committed Jun 17, 2018
commit affce4a05bc9a831dff8827c4d87df8a3a5b8852
47 changes: 25 additions & 22 deletions Lib/idlelib/idle_test/test_paragraph.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Test the functions and main class method of paragraph.py
"Test paragraph, coverage 76%."

from idlelib import paragraph as pg
import unittest
from idlelib import paragraph as fp
from idlelib.editor import EditorWindow
from tkinter import Tk, Text
from test.support import requires
from tkinter import Tk, Text
from idlelib.editor import EditorWindow


class Is_Get_Test(unittest.TestCase):
Expand All @@ -15,26 +16,26 @@ class Is_Get_Test(unittest.TestCase):
leadingws_nocomment = ' This is not a comment'

def test_is_all_white(self):
self.assertTrue(fp.is_all_white(''))
self.assertTrue(fp.is_all_white('\t\n\r\f\v'))
self.assertFalse(fp.is_all_white(self.test_comment))
self.assertTrue(pg.is_all_white(''))
self.assertTrue(pg.is_all_white('\t\n\r\f\v'))
self.assertFalse(pg.is_all_white(self.test_comment))

def test_get_indent(self):
Equal = self.assertEqual
Equal(fp.get_indent(self.test_comment), '')
Equal(fp.get_indent(self.trailingws_comment), '')
Equal(fp.get_indent(self.leadingws_comment), ' ')
Equal(fp.get_indent(self.leadingws_nocomment), ' ')
Equal(pg.get_indent(self.test_comment), '')
Equal(pg.get_indent(self.trailingws_comment), '')
Equal(pg.get_indent(self.leadingws_comment), ' ')
Equal(pg.get_indent(self.leadingws_nocomment), ' ')

def test_get_comment_header(self):
Equal = self.assertEqual
# Test comment strings
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(pg.get_comment_header(self.test_comment), '#')
Equal(pg.get_comment_header(self.trailingws_comment), '#')
Equal(pg.get_comment_header(self.leadingws_comment), ' #')
# Test non-comment strings
Equal(fp.get_comment_header(self.leadingws_nocomment), ' ')
Equal(fp.get_comment_header(self.test_nocomment), '')
Equal(pg.get_comment_header(self.leadingws_nocomment), ' ')
Equal(pg.get_comment_header(self.test_nocomment), '')


class FindTest(unittest.TestCase):
Expand Down Expand Up @@ -62,7 +63,7 @@ def runcase(self, inserttext, stopline, expected):
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)
self.assertEqual(pg.find_paragraph(text, tempindex), expected)
text.delete('1.0', 'end')

def test_find_comment(self):
Expand Down Expand Up @@ -161,7 +162,7 @@ class ReformatFunctionTest(unittest.TestCase):

def test_reformat_paragraph(self):
Equal = self.assertEqual
reform = fp.reformat_paragraph
reform = pg.reformat_paragraph
hw = "O hello world"
Equal(reform(' ', 1), ' ')
Equal(reform("Hello world", 20), "Hello world")
Expand Down Expand Up @@ -192,7 +193,7 @@ def test_reformat_comment(self):
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, " ")
result = pg.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?\"\"\"")
Expand All @@ -201,7 +202,7 @@ def test_reformat_comment(self):
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, "#")
result = pg.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?")
Expand All @@ -210,7 +211,7 @@ def test_reformat_comment(self):

class FormatClassTest(unittest.TestCase):
def test_init_close(self):
instance = fp.FormatParagraph('editor')
instance = pg.FormatParagraph('editor')
self.assertEqual(instance.editwin, 'editor')
instance.close()
self.assertEqual(instance.editwin, None)
Expand Down Expand Up @@ -269,14 +270,16 @@ class FormatEventTest(unittest.TestCase):
def setUpClass(cls):
requires('gui')
cls.root = Tk()
cls.root.withdraw()
editor = Editor(root=cls.root)
cls.text = editor.text.text # Test code does not need the wrapper.
cls.formatter = fp.FormatParagraph(editor).format_paragraph_event
cls.formatter = pg.FormatParagraph(editor).format_paragraph_event
# Sets the insert mark just after the re-wrapped and inserted text.

@classmethod
def tearDownClass(cls):
del cls.text, cls.formatter
cls.root.update_idletasks()
cls.root.destroy()
del cls.root

Expand Down
5 changes: 2 additions & 3 deletions Lib/idlelib/paragraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,5 @@ def get_comment_header(line):


if __name__ == "__main__":
import unittest
unittest.main('idlelib.idle_test.test_paragraph',
verbosity=2, exit=False)
from unittest import main
main('idlelib.idle_test.test_paragraph', verbosity=2, exit=False)