jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] enable automatic tk_tests

- pillow is needed to run tests, require it with test module
- get the show_dialog result and add some tests in testTkdialog
- use event loop and run skip_file() after few microseconds to press "skip"
- use event loop and run pressedOK() after few microseconds to press "Ok"
in TestTkinter and test text content

- decrease tk size because 1600/1000 looks too big

Change-Id: I2e1b3e2d7029fb311ec3ccc3bc7cf93ff5cd9cd0
---
M pywikibot/config.py
M tests/tk_tests.py
2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/pywikibot/config.py b/pywikibot/config.py
index 5a3626a..7207fec 100644
--- a/pywikibot/config.py
+++ b/pywikibot/config.py
@@ -538,8 +538,8 @@

# An indication of the size of your screen, or rather the size of the screen
# to be shown, for flickrripper
-tkhorsize = 1600
-tkvertsize = 1000
+tkhorsize = 1280
+tkvertsize = 800

# ############# EXTERNAL EDITOR SETTINGS ##############
# The command for the editor you want to use. If set to None, a simple Tkinter
diff --git a/tests/tk_tests.py b/tests/tk_tests.py
index f94dffd..430f4e3 100755
--- a/tests/tk_tests.py
+++ b/tests/tk_tests.py
@@ -42,11 +42,16 @@

def testTkdialog(self):
"""Test Tk dialog."""
- try:
- box = Tkdialog('foo', 'tests/data/MP_sounds.png', 'MP_sounds.png')
- box.show_dialog()
- except ImportError as e:
- pywikibot.warning(e)
+ desc = 'foo'
+ image = 'tests/data/images/MP_sounds.png'
+ filename = image.rsplit('/', 1)[1]
+ box = Tkdialog(desc, image, filename)
+ # skip after ~100 ms
+ box.root.after(100, lambda: box.skip_file())
+ description, name, skip = box.show_dialog()
+ self.assertEqual(description, desc)
+ self.assertEqual(name, filename)
+ self.assertTrue(skip)


class TestTkinter(TkinterTestsBase, DefaultSiteTestCase):
@@ -58,15 +63,17 @@
root = tkinter.Tk()
root.resizable(width=tkinter.FALSE, height=tkinter.FALSE)
root.title('pywikibot GUI')
- page = pywikibot.Page(pywikibot.Site(), 'Main Page')
+ page = pywikibot.Page(self.site, 'Main Page')
content = page.get()
myapp = EditBoxWindow(root)
- myapp.bind('<Control-d>', myapp.debug)
- v = myapp.edit(content, highlight=page.title())
- self.assertIsNone(v)
+ root.after(100, lambda: myapp.pressedOK())
+ text = myapp.edit(content, highlight=page.title())
+ self.assertIsNotNone(text)
+ self.assertIn('Main Page', text)


@require_modules('tkinter')
+@require_modules('PIL')
def setUpModule():
"""Skip tests if tkinter is not installed. Otherwise import it."""
global EditBoxWindow, Tkdialog, tkinter

To view, visit change 831105. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2e1b3e2d7029fb311ec3ccc3bc7cf93ff5cd9cd0
Gerrit-Change-Number: 831105
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged