Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1181232?usp=email )

Change subject: i18n: Make doctests for known_languages() more robust
......................................................................

i18n: Make doctests for known_languages() more robust

- Skip unstable slice of last 10 languages with +SKIP
- Reduce first slice to a stable 2 entries
- Use membership tests and flexible length check instead of fixed numbers

Change-Id: I06f1f275aa132cabe61f30596f1126131092ce26
---
M pywikibot/i18n.py
1 file changed, 10 insertions(+), 6 deletions(-)

Approvals:
  Xqt: Verified; Looks good to me, approved




diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index ef32722..685e918 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -913,15 +913,19 @@


 def known_languages() -> list[str]:
-    """All languages we have localizations for.
+    """Return all languages we have localizations for.

     >>> from pywikibot import i18n
-    >>> i18n.known_languages()[:10]
-    ['ab', 'aeb', 'af', 'am', 'an', 'ang', 'anp', 'ar', 'arc', 'arz']
-    >>> i18n.known_languages()[-10:]
+    >>> i18n.known_languages()[:2]
+    ['ab', 'aeb']
+    >>> i18n.known_languages()[-10:]  # doctest: +SKIP
     ['vo', 'vro', 'wa', 'war', 'xal', 'xmf', 'yi', 'yo', 'yue', 'zh']
-    >>> len(i18n.known_languages())
-    251
+    >>> len(i18n.known_languages()) > 250
+    True
+    >>> 'ab' in i18n.known_languages()
+    True
+    >>> 'zh' in i18n.known_languages()
+    True

     The implementation is roughly equivalent to:


--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1181232?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: I06f1f275aa132cabe61f30596f1126131092ce26
Gerrit-Change-Number: 1181232
Gerrit-PatchSet: 2
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