jenkins-bot has submitted this change and it was merged.
Change subject: Use messages in tests/i18n for tests ......................................................................
Use messages in tests/i18n for tests
'setup.py test' fails calling twtranslate as 'scripts' is not packaged.
Change-Id: I3cb4d071b4dce921e74e91af7b5b613a117e90b4 Original-Change-Id: Ie4f77a8ace594619fee98996cc4403915316b51b --- M pywikibot/i18n.py M tests/i18n_tests.py 2 files changed, 7 insertions(+), 7 deletions(-)
Approvals: John Vandenberg: Looks good to me, but someone else must approve Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py index fea4130..259b505 100644 --- a/pywikibot/i18n.py +++ b/pywikibot/i18n.py @@ -20,6 +20,9 @@
PLURAL_PATTERN = '{{PLURAL:(?:%()?([^)]*?)(?:)d)?|(.*?)}}'
+# Package name for the translation messages +messages_package_name = 'scripts.i18n' +
def _altlang(code): """Define fallback languages for particular languages. @@ -349,7 +352,7 @@ import table. """ package = twtitle.split("-")[0] - transdict = getattr(__import__("scripts.i18n", fromlist=[package]), package).msg + transdict = getattr(__import__(messages_package_name, fromlist=[package]), package).msg
code_needed = False # If a site is given instead of a code, use its language diff --git a/tests/i18n_tests.py b/tests/i18n_tests.py index f6e2c6e..af9e90c 100644 --- a/tests/i18n_tests.py +++ b/tests/i18n_tests.py @@ -6,9 +6,7 @@ # __version__ = '$Id$'
-import os from pywikibot import i18n -import shutil
from tests.utils import unittest
@@ -73,12 +71,11 @@
class TestTWN(unittest.TestCase): def setUp(self): - self.path = os.path.split(os.path.realpath(__file__))[0] - shutil.copyfile(os.path.join(self.path, 'i18n', 'test.py'), - os.path.join(self.path, '..', 'scripts', 'i18n', 'test.py')) + self.orig_messages_package_name = i18n.messages_package_name + i18n.messages_package_name = 'tests.i18n'
def tearDown(self): - os.remove(os.path.join(self.path, '..', 'scripts', 'i18n', 'test.py')) + i18n.messages_package_name = self.orig_messages_package_name
class TestTWTranslate(TestTWN):
pywikibot-commits@lists.wikimedia.org