jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] create DISPLAY environment variable to run tkinter tests

Change-Id: I912d9a5ad72231033c1fb6fddcfd773b359ec74f
---
M tests/tk_tests.py
1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/tests/tk_tests.py b/tests/tk_tests.py
index 58a283d..f94dffd 100755
--- a/tests/tk_tests.py
+++ b/tests/tk_tests.py
@@ -5,6 +5,7 @@
#
# Distributed under the terms of the MIT license.
#
+import os
import unittest
from contextlib import suppress

@@ -12,12 +13,33 @@
from tests.aspects import DefaultSiteTestCase, TestCase, require_modules


-class TestTkdialog(TestCase):
+class TkinterTestsBase(TestCase):

- """Test Tkdialog."""
+ """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'] = ':0.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):
+
+ """Test Tkdialog."""
+
def testTkdialog(self):
"""Test Tk dialog."""
try:
@@ -27,12 +49,10 @@
pywikibot.warning(e)


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

"""Test Tkinter."""

- net = True
-
def testTkinter(self):
"""Test Tkinter window."""
root = tkinter.Tk()

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

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