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

Change subject: [Bugfix] Add "." to family.CODE_CHARACTERS
......................................................................

[Bugfix] Add "." to family.CODE_CHARACTERS

"." was introduced with 336b24961 for Vikidia test codes,
but was not recognized by Family.load().

- add "." to family.CODE_CHARACTERS
- update warning message
- update family_tests

Bug: T438622
Change-Id: Iad9cd777549ca68dda0236fe7b0c15adbb3427b7
---
M pywikibot/family.py
M tests/family_tests.py
2 files changed, 9 insertions(+), 4 deletions(-)

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




diff --git a/pywikibot/family.py b/pywikibot/family.py
index 0a50fb4..7624eb0 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -36,8 +36,9 @@
 # Legal characters for Family.name and Family.langs keys
 NAME_CHARACTERS = string.ascii_letters + string.digits
 # nds_nl code alias requires "_"
+# vikidia uses "." for test codes
 # dash must be the last char to be reused as regex
-CODE_CHARACTERS = string.ascii_lowercase + string.digits + '_-'
+CODE_CHARACTERS = string.ascii_lowercase + string.digits + '_.-'


 class Family:
@@ -408,7 +409,8 @@
             if not all(x in CODE_CHARACTERS for x in code):
                 warnings.warn(
                     f'Family {cls.name} code {code} must be ASCII lowercase'
-                    ' letters and digits [a-z0-9] or underscore/dash [_-]',
+                    ' letters and digits [a-z0-9] or special characters '
+                    f'[{CODE_CHARACTERS[36:]}]',
                     FamilyMaintenanceWarning,
                     stacklevel=2,
                 )
diff --git a/tests/family_tests.py b/tests/family_tests.py
index 313ccf6..e302d99 100755
--- a/tests/family_tests.py
+++ b/tests/family_tests.py
@@ -8,11 +8,12 @@
 from __future__ import annotations

 import unittest
+import warnings
 from collections.abc import Mapping
 from contextlib import suppress

 import pywikibot
-from pywikibot.exceptions import UnknownFamilyError
+from pywikibot.exceptions import FamilyMaintenanceWarning, UnknownFamilyError
 from pywikibot.family import Family, SingleSiteFamily
 from pywikibot.tools import suppress_warnings
 from tests.aspects import PatchingTestCase, TestCase
@@ -29,7 +30,9 @@
         """Test that a family can be loaded via Family.load."""
         for name in pywikibot.config.family_files:
             with self.subTest(family=name):
-                f = Family.load(name)
+                with warnings.catch_warnings():
+                    warnings.simplefilter('error', FamilyMaintenanceWarning)
+                    f = Family.load(name)
                 self.assertIsInstance(f.langs, dict)
                 self.assertTrue(f.langs)


--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1343288?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: Iad9cd777549ca68dda0236fe7b0c15adbb3427b7
Gerrit-Change-Number: 1343288
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Linedwell <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to