summaryrefslogtreecommitdiffstats
path: root/Lib/idlelib/idle_test
diff options
context:
space:
mode:
authorLouie Lu <me@louie.lu>2017-05-17 21:51:31 (GMT)
committerterryjreedy <tjreedy@udel.edu>2017-05-17 21:51:31 (GMT)
commitba365da9cee8901fad08ab0b61c7489c110e5c97 (patch)
treefa52c68a6f1b574454639de635c59dff36cda42b /Lib/idlelib/idle_test
parentab4413a7e9bda95b6fcd517073e2a51dafaa1624 (diff)
downloadcpython-ba365da9cee8901fad08ab0b61c7489c110e5c97.zip
cpython-ba365da9cee8901fad08ab0b61c7489c110e5c97.tar.gz
cpython-ba365da9cee8901fad08ab0b61c7489c110e5c97.tar.bz2
bpo-30303: IDLE: Add _utest argument to textview (#1499)
Diffstat (limited to 'Lib/idlelib/idle_test')
-rw-r--r--Lib/idlelib/idle_test/test_textview.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/Lib/idlelib/idle_test/test_textview.py b/Lib/idlelib/idle_test/test_textview.py
index f018f5e..67fc0b7 100644
--- a/Lib/idlelib/idle_test/test_textview.py
+++ b/Lib/idlelib/idle_test/test_textview.py
@@ -13,7 +13,7 @@ requires('gui')
import unittest
import os
-from tkinter import Tk
+from tkinter import Tk, Button
from idlelib.idle_test.mock_idle import Func
from idlelib.idle_test.mock_tk import Mbox_func
@@ -96,5 +96,45 @@ class ViewFunctionTest(unittest.TestCase):
self.assertIsNone(view)
+class ButtonClickTextViewTest(unittest.TestCase):
+
+ def setUp(self):
+ self.view = None
+ self.called = False
+
+ def tearDown(self):
+ if self.view:
+ self.view.destroy()
+
+ def test_view_text_bind_with_button(self):
+ def _command():
+ self.called = True
+ self.view = tv.view_text(root, 'TITLE_TEXT', 'COMMAND', _utest=True)
+ button = Button(root, text='BUTTON', command=_command)
+ button.invoke()
+ self.addCleanup(button.destroy)
+
+ self.assertEqual(self.called, True)
+ self.assertEqual(self.view.title(), 'TITLE_TEXT')
+ self.assertEqual(self.view.textView.get('1.0', '1.end'), 'COMMAND')
+
+ def test_view_file_bind_with_button(self):
+ def _command():
+ self.called = True
+ self.view = tv.view_file(root, 'TITLE_FILE', __file__, _utest=True)
+ button = Button(root, text='BUTTON', command=_command)
+ button.invoke()
+ self.addCleanup(button.destroy)
+
+ self.assertEqual(self.called, True)
+ self.assertEqual(self.view.title(), 'TITLE_FILE')
+ with open(__file__) as f:
+ self.assertEqual(self.view.textView.get('1.0', '1.end'),
+ f.readline().strip())
+ f.readline()
+ self.assertEqual(self.view.textView.get('3.0', '3.end'),
+ f.readline().strip())
+
+
if __name__ == '__main__':
unittest.main(verbosity=2)