jenkins-bot has submitted this change and it was merged.
Change subject: Tk: added missing config vars and tests ......................................................................
Tk: added missing config vars and tests
Added two variables tkhorsize & tkvertsize to config2.py and added new test file in tests/tk_tests.py with tests for Tkinter and Tkdialog and disabled them on Travis.
Bug: T75025 Change-Id: I51545f8f1a3e841bcfc6fe9b1da90f4265770725 --- M pywikibot/config2.py M pywikibot/userinterfaces/gui.py A tests/tk_tests.py 3 files changed, 75 insertions(+), 15 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py index 2a2be84..3d2a674 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -343,6 +343,11 @@ except: colorized_output = False
+# An indication of the size of your screen, or rather the size of the screen +# to be shown, for flickrripper +tkhorsize = 1600 +tkvertsize = 1000 + # ############# EXTERNAL EDITOR SETTINGS ############## # The command for the editor you want to use. If set to None, a simple Tkinter # editor will be used. diff --git a/pywikibot/userinterfaces/gui.py b/pywikibot/userinterfaces/gui.py index 517178f..8bd2800 100644 --- a/pywikibot/userinterfaces/gui.py +++ b/pywikibot/userinterfaces/gui.py @@ -439,18 +439,3 @@ self.listbox.config(height=laenge, width=maxbreite + 2) # wait for user to push a button which will destroy (close) the window return self.list - - -if __name__ == "__main__": - import pywikibot - try: - root = Tkinter.Tk() - root.resizable(width=Tkinter.FALSE, height=Tkinter.FALSE) - root.title("pywikibot GUI") - page = pywikibot.Page(pywikibot.Site(), u'Main Page') - content = page.get() - myapp = EditBoxWindow(root) - myapp.bind("<Control-d>", myapp.debug) - v = myapp.edit(content, highlight=page.title()) - finally: - pywikibot.stopme() diff --git a/tests/tk_tests.py b/tests/tk_tests.py new file mode 100644 index 0000000..1b94a66 --- /dev/null +++ b/tests/tk_tests.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +"""Tests for the Tk UI.""" +# +# (C) Pywikibot team, 2008-2014 +# +# Distributed under the terms of the MIT license. +# +__version__ = '$Id$' + +import os +import sys + +if os.environ.get('PYWIKIBOT2_TEST_GUI', '0') == '1': + if sys.version_info[0] > 2: + import tkinter as Tkinter + else: + import Tkinter +import pywikibot +from scripts import flickrripper +from pywikibot.userinterfaces.gui import EditBoxWindow + +from tests.aspects import unittest, TestCase, DefaultSiteTestCase + + +class TestFlickrRipper(TestCase): + + """Test Tkdialog.""" + + net = True + + @classmethod + def setUpClass(cls): + if os.environ.get('PYWIKIBOT2_TEST_GUI', '0') != '1': + raise unittest.SkipTest('FlickrRipper tests are disabled on Travis-CI') + super(TestFlickrRipper, cls).setUpClass() + + def testTkdialog(self): + box = flickrripper.Tkdialog('foo', 'tests/data/MP_sounds.png', 'MP_sounds.png') + box.run() + + +class TestTkinter(DefaultSiteTestCase): + + """Test Tkinter.""" + + net = True + + @classmethod + def setUpClass(cls): + if os.environ.get('PYWIKIBOT2_TEST_GUI', '0') != '1': + raise unittest.SkipTest('Tkinter tests are disabled on Travis-CI') + super(TestTkinter, cls).setUpClass() + + def testTkinter(self): + root = Tkinter.Tk() + root.resizable(width=Tkinter.FALSE, height=Tkinter.FALSE) + root.title("pywikibot GUI") + page = pywikibot.Page(pywikibot.Site(), u'Main Page') + content = page.get() + myapp = EditBoxWindow(root) + myapp.bind("<Control-d>", myapp.debug) + v = myapp.edit(content, highlight=page.title()) + assert v is None + + +if __name__ == '__main__': + try: + unittest.main() + except SystemExit: + pass
pywikibot-commits@lists.wikimedia.org