jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/831825 )
Change subject: [tests] Deactivate gui_tests on github
......................................................................
[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(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
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 https://gerrit.wikimedia.org/r/c/pywikibot/core/+/831825
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I4101b6bff0ec140ad4acc8bbb7c8161ef4e3f7ba
Gerrit-Change-Number: 831825
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/831600 )
Change subject: [IMPR] Improvements for dae module
......................................................................
[IMPR] Improvements for dae module
- add _en_period to Create century and millenium format function
for 'en' language to reduce similar code
- predefine brMonthNames like enMonthNames and waMonthNames
- simplify makeMonthNamedList
- update documentation
Change-Id: I3c2d190e5696c52a42f142072c22f98f3f573dbc
---
M pywikibot/date.py
1 file changed, 28 insertions(+), 44 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py
index bd37377..65d533e 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -33,12 +33,13 @@
#
# Different collections of well known formats
#
+brMonthNames = ['Genver', "C'hwevrer", 'Meurzh', 'Ebrel', 'Mae', 'Mezheven',
+ 'Gouere', 'Eost', 'Gwengolo', 'Here', 'Du', 'Kerzu']
enMonthNames = ['January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',
'December']
waMonthNames = ['djanvî', 'fevrî', 'måss', 'avri', 'may', 'djun', 'djulete',
'awousse', 'setimbe', 'octôbe', 'nôvimbe', 'decimbe']
-
dayMnthFmts = ['Day_' + str(s) for s in enMonthNames] # e.g. 'Day_January'
yrMnthFmts = ['Year_' + str(s) for s in enMonthNames] # e.g. 'Year_January'
@@ -558,9 +559,7 @@
# Predefined month names which are needed at import time
months = {
- 'br': lambda v: slh(v, ['Genver', "C'hwevrer", 'Meurzh', 'Ebrel',
- 'Mae', 'Mezheven', 'Gouere', 'Eost',
- 'Gwengolo', 'Here', 'Du', 'Kerzu']),
+ 'br': lambda v: slh(v, brMonthNames),
'en': lambda v: slh(v, enMonthNames),
'ja': lambda v: slh(v, makeMonthList('%d月')),
'ko': lambda v: slh(v, makeMonthList('%d월')),
@@ -703,6 +702,18 @@
return len(self.data)
+def _en_period(period: str):
+ """Create century and millenium format function for ``en`` language."""
+ return lambda m: multi(m, [
+ (lambda v: dh_centuryAD(v, '%dst ' + period),
+ lambda p: p == 1 or (p > 20 and p % 10 == 1)),
+ (lambda v: dh_centuryAD(v, '%dnd ' + period),
+ lambda p: p == 2 or (p > 20 and p % 10 == 2)),
+ (lambda v: dh_centuryAD(v, '%drd ' + period),
+ lambda p: p == 3 or (p > 20 and p % 10 == 3)),
+ (lambda v: dh_centuryAD(v, '%dth ' + period), alwaysTrue)])
+
+
formats = {
'MonthName': MonthNames(),
'Number': {
@@ -1064,14 +1075,7 @@
'el': lambda m: multi(m, [
(lambda v: dh_centuryAD(v, '%dός αιώνας'), lambda p: p == 20),
(lambda v: dh_centuryAD(v, '%dος αιώνας'), alwaysTrue)]),
- 'en': lambda m: multi(m, [
- (lambda v: dh_centuryAD(v, '%dst century'),
- lambda p: p == 1 or (p > 20 and p % 10 == 1)),
- (lambda v: dh_centuryAD(v, '%dnd century'),
- lambda p: p == 2 or (p > 20 and p % 10 == 2)),
- (lambda v: dh_centuryAD(v, '%drd century'),
- lambda p: p == 3 or (p > 20 and p % 10 == 3)),
- (lambda v: dh_centuryAD(v, '%dth century'), alwaysTrue)]),
+ 'en': _en_period('century'),
'eo': lambda v: dh_centuryAD(v, '%d-a jarcento'),
'es': lambda v: dh_centuryAD(v, 'Siglo %R'),
'et': lambda v: dh_centuryAD(v, '%d. sajand'),
@@ -1192,14 +1196,7 @@
'da': lambda v: dh_centuryBC(v, '%d. århundrede f.Kr.'),
'de': lambda v: dh_centuryBC(v, '%d. Jahrhundert v. Chr.'),
'el': lambda v: dh_centuryBC(v, '%dος αιώνας π.Χ.'),
- 'en': lambda m: multi(m, [
- (lambda v: dh_centuryBC(v, '%dst century BC'),
- lambda p: p == 1 or (p > 20 and p % 10 == 1)),
- (lambda v: dh_centuryBC(v, '%dnd century BC'),
- lambda p: p == 2 or (p > 20 and p % 10 == 2)),
- (lambda v: dh_centuryBC(v, '%drd century BC'),
- lambda p: p == 3 or (p > 20 and p % 10 == 3)),
- (lambda v: dh_centuryBC(v, '%dth century BC'), alwaysTrue)]),
+ 'en': _en_period('century BC'),
'eo': lambda v: dh_centuryBC(v, '%d-a jarcento a.K.'),
'es': lambda v: dh_centuryBC(v, 'Siglo %R adC'),
'et': lambda v: dh_centuryBC(v, '%d. aastatuhat eKr'),
@@ -1276,15 +1273,7 @@
'cs': lambda v: dh_millenniumAD(v, '%d. tisíciletí'),
'de': lambda v: dh_millenniumAD(v, '%d. Jahrtausend'),
'el': lambda v: dh_millenniumAD(v, '%dη χιλιετία'),
- 'en': lambda m: multi(m, [
- (lambda v: dh_millenniumAD(v, '%dst millennium'),
- lambda p: p == 1 or (p > 20 and p % 10 == 1)),
- (lambda v: dh_millenniumAD(v, '%dnd millennium'),
- lambda p: p == 2 or (p > 20 and p % 10 == 2)),
- (lambda v: dh_millenniumAD(v, '%drd millennium'),
- lambda p: p == 3 or (p > 20 and p % 10 == 3)),
- (lambda v: dh_millenniumAD(v, '%dth millennium'),
- alwaysTrue)]),
+ 'en': _en_period('millennium'),
'es': lambda v: dh_millenniumAD(v, '%R milenio'),
'fa': lambda v: dh_millenniumAD(v, 'هزاره %R (میلادی)'),
@@ -1715,23 +1704,20 @@
return [pattern % m for m in range(1, 13)]
-def makeMonthNamedList(lang: str, pattern: str,
+def makeMonthNamedList(lang: str, pattern: str = '%s',
makeUpperCase: Optional[bool] = None) -> List[str]:
"""Create a list of 12 elements based on the name of the month.
- The language-dependent month name is used as a formatting argument to the
- pattern. The pattern must be have one %s that will be replaced by the
- localized month name.
- Use %%d for any other parameters that should be preserved.
-
+ The language-dependent month name is used as a formatting argument
+ to the *pattern*. The *pattern* must be have one ``%s`` that will be
+ replaced by the localized month name. Use ``%%`` for any other
+ parameters that should be preserved.
"""
if makeUpperCase is None:
return [pattern % monthName(lang, m) for m in range(1, 13)]
- if makeUpperCase:
- f = first_upper
- else:
- f = first_lower
- return [pattern % f(monthName(lang, m)) for m in range(1, 13)]
+
+ func = first_upper if makeUpperCase else first_lower
+ return [pattern % func(monthName(lang, m)) for m in range(1, 13)]
# Add day of the month formats to the formatting table: "en:May 15"
@@ -1864,13 +1850,11 @@
'(lambda v: dh_dayOfMnth(v, "%d d\' {mname}"), alwaysTrue)])'
)
-# Brazil uses '1añ' for the 1st of every month, and number without suffix for
-# all other days
-brMonthNames = makeMonthNamedList('br', '%s', True)
-
for i in range(12):
pattern = _vowel_pattern if i in (3, 7, 9) else _consonant_pattern
formats[dayMnthFmts[i]]['wa'] = eval(pattern.format(mname=waMonthNames[i]))
+ # Brazil uses '1añ' for the 1st of every month, and number without suffix
+ # for all other days
formats[dayMnthFmts[i]]['br'] = eval(
'lambda m: multi(m, ['
'(lambda v: dh_dayOfMnth(v, "%dañ {mname}"), lambda p: p == 1), '
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/831600
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I3c2d190e5696c52a42f142072c22f98f3f573dbc
Gerrit-Change-Number: 831600
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged