jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] Deactivate gui_tests on github

Appveyor is the only CI test where gui_tests.py can be run.
'tk_inter' is not installed for Jenkins tests.
github action always fails with 'couldn't connect to display ":1.0"' error.
Therefore restore PYWIKIBOT_TEST_GUI environment variable and remove
DISPLAY environment variable setting.

Bug: T317618
Change-Id: I4101b6bff0ec140ad4acc8bbb7c8161ef4e3f7ba
---
M .appveyor.yml
M tests/README.rst
M tests/gui_tests.py
3 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/.appveyor.yml b/.appveyor.yml
index f534951..d7a1176 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -9,6 +9,7 @@
PYWIKIBOT_PASSWD_FILE: "%appdata%\\Pywikibot\\passwordfile"

PYSETUP_TEST_EXTRAS: "1"
+ PYWIKIBOT_TEST_GUI: "1"
PYWIKIBOT_TEST_RUNNING: "1"

matrix:
diff --git a/tests/README.rst b/tests/README.rst
index cbaee97..d7c2bba 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -109,6 +109,13 @@
Enable script tests running automatically without specifying a generator.
The scripts are listed in :attr:`tests.script_tests.auto_run_script_list`.
Currently only *deeptest* uses it.
+
+**PYWIKIBOT_TEST_GUI**
+ Enable :mod:`tests.gui_tests`. Used for Appveyor tests. Github actions would
+ fail due to ``couldn't connect to display ":1.0"`` error. Set this environment
+ variable to run this test locally::
+
+ PYWIKIBOT_TEST_GUI=1

**PYWIKIBOT_TEST_MODULES**
Only run tests given with this environment variable. Multiple tests must be
diff --git a/tests/gui_tests.py b/tests/gui_tests.py
index 2a6f709..5439738 100755
--- a/tests/gui_tests.py
+++ b/tests/gui_tests.py
@@ -13,33 +13,12 @@
from tests.aspects import DefaultSiteTestCase, TestCase, require_modules


-class TkinterTestsBase(TestCase):
-
- """TestCase base for Tkinter tests."""
-
- net = True
-
- @classmethod
- def setUpClass(cls):
- """Set virtual display environment."""
- super().setUpClass()
- cls.env = os.environ.get('DISPLAY')
- os.environ['DISPLAY'] = ':1.0'
-
- @classmethod
- def tearDownClass(cls):
- """Restore the display environment value."""
- if not cls.env:
- del os.environ['DISPLAY']
- else:
- os.environ['DISPLAY'] = cls.env
- super().tearDownClass()
-
-
-class TestTkdialog(TkinterTestsBase):
+class TestTkdialog(TestCase):

"""Test Tkdialog."""

+ net = True
+
def test_tk_dialog(self):
"""Test Tk dialog."""
desc = 'foo'
@@ -54,10 +33,12 @@
self.assertTrue(skip)


-class TestTkinter(TkinterTestsBase, DefaultSiteTestCase):
+class TestTkinter(DefaultSiteTestCase):

"""Test Tkinter."""

+ net = True
+
def test_tkinter(self):
"""Test Tkinter window."""
root = tkinter.Tk()
@@ -77,8 +58,13 @@
def setUpModule():
"""Skip tests if tkinter or PIL is not installed.

- Otherwise import modules.
+ Also skip test if ``PYWIKIBOT_TEST_GUI`` environment variable is not
+ set. Otherwise import modules and run tests.
"""
+ if os.environ.get('PYWIKIBOT_TEST_GUI', '0') != '1':
+ raise unittest.SkipTest('Tkinter tests are not enabled. '
+ '(set PYWIKIBOT_TEST_GUI=1 to enable)')
+
global EditBoxWindow, Tkdialog, tkinter
import tkinter
from pywikibot.userinterfaces.gui import EditBoxWindow, Tkdialog

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

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