jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1155252?usp=email )

Change subject: tests: Remove l10n_tests
......................................................................

tests: Remove l10n_tests

redirect-broken-redirect-template and archivebot-archiveheader are to
be removed. It is no longer necessary to test these templates. Other
test are part of i18n.

Bug: T396399
Bug: T396447
Change-Id: I44a13625969f166f4da58d18b68ccf61c6d13bb1
---
M tests/__init__.py
D tests/l10n_tests.py
M tox.ini
3 files changed, 0 insertions(+), 144 deletions(-)

Approvals:
  jenkins-bot: Verified
  Xqt: Looks good to me, approved




diff --git a/tests/__init__.py b/tests/__init__.py
index 530c2ea..dca5690 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -92,7 +92,6 @@
     'interwiki_graph',
     'interwiki_link',
     'interwikimap',
-    'l10n',  # pywikibot-i18n repository runs it too
     'link',
     'linter',
     'logentries',
@@ -156,7 +155,6 @@
     'generate_user_files',
     'harvest_template',
     'interwikidata',
-    'l10n',
     'make_dist',
     'noreferences',
     'patrolbot',
diff --git a/tests/l10n_tests.py b/tests/l10n_tests.py
deleted file mode 100755
index b16d40a..0000000
--- a/tests/l10n_tests.py
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/usr/bin/env python3
-"""Test valid templates."""
-#
-# (C) Pywikibot team, 2015-2024
-#
-# Distributed under the terms of the MIT license.
-#
-from __future__ import annotations
-
-import unittest
-from contextlib import suppress
-from itertools import chain
-
-import pywikibot
-from pywikibot import i18n
-from pywikibot.textlib import extract_templates_and_params_regex_simple
-from tests.aspects import MetaTestCaseClass, TestCase
-
-
-PACKAGES = (
-    'redirect-broken-redirect-template',  # speedy deletion template
-    'archivebot-archiveheader',  # archive header template
-)
-
-
-class TestValidTemplateMeta(MetaTestCaseClass):
-
-    """Test meta class."""
-
-    def __new__(cls, name, bases, dct):
-        """Create the new class."""
-        def test_method(site, package):
-
-            def test_template(self) -> None:
-                """Test validity of template."""
-                lang = site.lang
-                if lang not in keys:
-                    return
-
-                if not i18n.twhas_key(lang, package):
-                    return
-
-                msg = i18n.twtranslate(lang, package, fallback=False)
-
-                # check whether the message contains a template
-                templates = extract_templates_and_params_regex_simple(msg)
-                self.assertIsInstance(templates, list)
-                self.assertIsNotEmpty(templates)
-
-                # known problems
-                if (package == PACKAGES[0] and site.code in ['simple', 'test2']
-                        or package == PACKAGES[1] and site.code == 'test'):
-                    raise unittest.SkipTest(
-                        f"{site} wiki has '{site.lang}' language code but "
-                        f"missing template for package '{package}'. Must be "
-                        'solved by the corresponding script.'
-                    )
-
-                # check whether template exists
-                title = templates[0][0]
-                page = pywikibot.Page(site, title, ns=10)
-                self.assertTrue(
-                    page.exists(),
-                    msg=f'Invalid L10N in package "{package}"\n'
-                    f'template "{title}" does not exist for lang '
-                    f'"{site.lang}" on site "{site}"'
-                )
-
-            return test_template
-
-        # create test methods for package messages processed by unittest
-        site = pywikibot.Site(dct['code'], dct['family'])
-        codes = site.family.codes
-        del site
-        for package in PACKAGES:
-            keys = i18n.twget_keys(package)
-            for code in codes:
-                current_site = pywikibot.Site(code, dct['family'])
-                test_name = f'test_{package}_{code}'.replace('-', '_')
-                cls.add_method(
-                    dct, test_name, test_method(current_site, package),
-                    doc_suffix=f'{package} and language {code}')
-
-        return super().__new__(cls, name, bases, dct)
-
-
-class TestValidTemplate(TestCase, metaclass=TestValidTemplateMeta):
-
-    """Test cases L10N message templates processed by unittest."""
-
-    family = 'wikipedia'
-    code = 'en'
-
-    @classmethod
-    def setUpClass(cls) -> None:
-        """Skip test gracefully if i18n package is missing."""
-        super().setUpClass()
-        if not i18n.messages_available():
-            raise unittest.SkipTest(
-                f'i18n messages package {i18n._messages_package_name!r} not'
-                ' available.')
-
-
-class TestPackages(TestCase):
-
-    """Other test L10N cases processed by unittest."""
-
-    net = False
-
-    def test_valid_package(self) -> None:
-        """Test whether package has entries."""
-        for package in chain(['cosmetic_changes-standalone',
-                              'pywikibot-cosmetic-changes'], PACKAGES):
-            keys = i18n.twget_keys(package)
-            with self.subTest(package=package):
-                self.assertIsNotEmpty(keys)
-                self.assertIn('en', keys)
-
-    def test_package_bundles(self) -> None:
-        """Test whether package bundles has valid entries."""
-        langs = i18n.known_languages()
-        self.assertIsInstance(langs, list)
-        self.assertIsNotEmpty(langs)
-        for dirname in i18n.bundles(stem=True):
-            for lang in langs:
-                with self.subTest(bundle=dirname, lang=lang):
-                    bundle = i18n._get_bundle(lang, dirname)
-                    if lang in ('en', 'qqq'):
-                        self.assertIsNotEmpty(bundle)
-                    for key in bundle:
-                        if key == '@metadata':
-                            continue
-                        self.assertTrue(
-                            key.startswith(dirname),
-                            f'{key!r} does not start with {dirname!r}'
-                        )
-
-
-if __name__ == '__main__':
-    with suppress(SystemExit):
-        unittest.main()
diff --git a/tox.ini b/tox.ini
index 58e901d..de53fd6 100644
--- a/tox.ini
+++ b/tox.ini
@@ -229,4 +229,3 @@
 minversion = 7.0.1
 testpaths = tests
 python_files = *_tests.py
-addopts = --ignore=tests/l10n_tests.py

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1155252?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I44a13625969f166f4da58d18b68ccf61c6d13bb1
Gerrit-Change-Number: 1155252
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to