tests.i18n_tests module#
Test i18n module.
- class tests.i18n_tests.InputTestCase(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin,TWNTestCaseBase,UserInterfaceLangTestCase,PwbTestCaseTest i18n.input.
- abstract_class = False#
- alt_code = 'nb'#
- code = 'nn'#
- family = 'wikipedia'#
- message = 'pywikibot-enter-category-name'#
- message_package = 'scripts.i18n'#
- net = True#
- pwb = True#
- site = True#
- sites = {'wikipedia:nn': {'code': 'nn', 'family': 'wikipedia'}}#
- class tests.i18n_tests.MissingPackageTestCase(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin,TWNSetMessagePackageBase,UserInterfaceLangTestCase,DefaultSiteTestCaseTest missing messages package.
- abstract_class = False#
- code = 'test'#
- family = 'wikipedia'#
- message_package = 'scripts.foobar.i18n'#
- net = True#
- site = True#
- sites = {'wikipedia:test': {'code': 'test', 'family': 'wikipedia'}}#
- class tests.i18n_tests.PywikibotPackageTestCase(*args, **kwargs)[source]#
Bases:
CheckHostnameMixin,TestCaseTest pywikibot i18n package.
- abstract_class = False#
- code = 'de'#
- family = 'wikipedia'#
- net = True#
- site = True#
- sites = {'wikipedia:de': {'code': 'de', 'family': 'wikipedia'}}#
- class tests.i18n_tests.Site(code, family='wikipedia')[source]#
Bases:
objectAn object holding code and family, duck typing a pywikibot Site.
- class tests.i18n_tests.TWNSetMessagePackageBase(*args, **kwargs)[source]#
Bases:
TestCasePartial base class for TranslateWiki tests.
- abstract_class = True#
- message_package = None#
- class tests.i18n_tests.TWNTestCaseBase(*args, **kwargs)[source]#
Bases:
TWNSetMessagePackageBaseBase class for TranslateWiki tests.
- abstract_class = True#
- class tests.i18n_tests.TestExtractPlural(*args, **kwargs)[source]#
Bases:
DisableSiteMixin,TestCaseTest extracting plurals from a dummy string.
- abstract_class = False#
- class tests.i18n_tests.TestFallbackTranslate(*args, **kwargs)[source]#
Bases:
DisableSiteMixin,TestCaseTest translate method with fallback True.
- abstract_class = False#
- msg_localized = {'en': 'test-localized EN', 'fy': 'test-localized FY', 'nl': 'test-localized NL'}#
- msg_no_english = {'ja': 'test-no-english JA'}#
- msg_non_localized = {'en': 'test-non-localized EN'}#
- msg_semi_localized = {'en': 'test-semi-localized EN', 'nl': 'test-semi-localized NL'}#
- class tests.i18n_tests.TestTWTranslate(*args, **kwargs)[source]#
Bases:
DisableSiteMixin,TWNTestCaseBaseTest twtranslate method.
- abstract_class = False#
- message_package = 'tests.i18n'#
- class tests.i18n_tests.TestTranslate(*args, **kwargs)[source]#
Bases:
DisableSiteMixin,TestCaseTest translate method with fallback True.
- abstract_class = False#
- test_translate_commons()[source]#
Test localization with xdict for commons.
Test whether the localzation is found either with the Site object or with the site code.
- test_translate_de()[source]#
Test localization fallbacks for ‘de’ with xdict.
‘de’ key is defined in a nested ‘wikipedia’ sub dict. This should always fall back to this nested ‘wikipedia’ entry.
- test_translate_en()[source]#
Test localization fallbacks for ‘en’ with xdict.
‘en’ key is defined directly in xdict. This topmost key goes over site specific key. Therefore ‘test-localized WS-EN’ is not given back.
- test_translate_fy()[source]#
Test localization fallbacks for ‘fy’ with xdict.
‘fy’ key is defined in ‘wikipedia’ and ‘wikisource’ sub dicts. They should have different localizations for these two families but ‘wikisource’ should have a fallback to the ‘wikipedia’ entry.
Note: If the translate code is given as string, the result depends on the current config.family entry. Therefore there is no test with the code given as string.
- test_translate_ja()[source]#
Test localization fallbacks for ‘ja’ with xdict.
‘ja’ key is defined in ‘wkisource’ sub dict only. Therefore there is no fallback to the ‘wikipedia’ entry and the localization result is None.
- test_translate_nl()[source]#
Test localization fallbacks for ‘nl’ with xdict.
‘nl’ key is defined in ‘wikipedia’ sub dict. Therefore all localizations have a fallback to the ‘wikipedia’ entry.
- xdict = {'commons': 'test-localized COMMONS', 'en': 'test-localized EN', 'wikipedia': {'fy': 'test-localized WP-FY', 'nl': 'test-localized WP-NL', 'wikipedia': {'de': 'test-localized WP-DE'}}, 'wikisource': {'en': 'test-localized WS-EN', 'fy': 'test-localized WS-FY', 'ja': 'test-localized WS-JA'}}#