jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/346159 )
Change subject: [IMPR] use extract_templates_and_params_regex_simple for template
validation
......................................................................
[IMPR] use extract_templates_and_params_regex_simple for template validation
- the given regex can be replaced by the textlib library method
textlib.extract_templates_and_params_regex_simple()
Change-Id: I58d93e5cb2f7ee0823880b53fb98db9344c1c217
---
M tests/l10n_tests.py
1 file changed, 6 insertions(+), 6 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/l10n_tests.py b/tests/l10n_tests.py
index 3a09e98..ed1dd19 100644
--- a/tests/l10n_tests.py
+++ b/tests/l10n_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Test valid templates."""
#
-# (C) Pywikibot team, 2015
+# (C) Pywikibot team, 2015-2017
#
# Distributed under the terms of the MIT license.
#
@@ -9,10 +9,9 @@
__version__ = '$Id$'
-import re
-
import pywikibot
from pywikibot import i18n
+from pywikibot.textlib import extract_templates_and_params_regex_simple
from tests.aspects import unittest, MetaTestCaseClass, TestCase
from tests.utils import add_metaclass
@@ -39,8 +38,9 @@
msg = i18n.twtranslate(lang, package, fallback=False)
if msg:
# check whether the message contains a template
- template = re.findall(u'.*?{{(.*?)[|}]', msg)
- self.assertTrue(template)
+ templates = extract_templates_and_params_regex_simple(msg)
+ self.assertIsInstance(templates, list)
+ self.assertGreater(len(templates), 0)
# known problem
if site.code == 'simple':
@@ -49,7 +49,7 @@
"missing template. Must be solved by the "
"corresponding script.")
# check whether template exists
- title = template[0]
+ title = templates[0][0]
page = pywikibot.Page(site, title, ns=10)
self.assertTrue(page.exists())
--
To view, visit
https://gerrit.wikimedia.org/r/346159
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I58d93e5cb2f7ee0823880b53fb98db9344c1c217
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>