jenkins-bot has submitted this change and it was merged.
Change subject: tests should use tests/i18n
......................................................................
tests should use tests/i18n
'setup.py test' fails calling twtranslate as 'scripts' is not packaged.
use messages in tests/i18n for tests.
Change-Id: Ie4f77a8ace594619fee98996cc4403915316b51b
---
M pywikibot/config2.py
M pywikibot/i18n.py
M tests/i18n_tests.py
3 files changed, 10 insertions(+), 5 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 87883fe..111c633 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -624,6 +624,9 @@
# if the user has already installed the library.
use_mwparserfromhell = True
+# location of i18n messages for scripts
+i18n_dir = 'scripts/i18n'
+
# End of configuration section
# ============================
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index c204121..4ef33c0 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -12,6 +12,7 @@
#
import re
+from os import sep as os_dir_sep
import locale
from pywikibot import Error
from .plural import plural_rules
@@ -348,7 +349,8 @@
import table.
"""
package = twtitle.split("-")[0]
- transdict = getattr(__import__("scripts.i18n", fromlist=[package]),
package).msg
+ import_dir = config.i18n_dir[:].replace(os_dir_sep, '.')
+ transdict = getattr(__import__(import_dir, 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..ba47238 100644
--- a/tests/i18n_tests.py
+++ b/tests/i18n_tests.py
@@ -8,6 +8,7 @@
import os
from pywikibot import i18n
+from pywikibot import config2 as config
import shutil
from tests.utils import unittest
@@ -73,12 +74,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_i18n_dir = config.i18n_dir
+ config.i18n_dir = 'tests/i18n'
def tearDown(self):
- os.remove(os.path.join(self.path, '..', 'scripts',
'i18n', 'test.py'))
+ config.i18n_dir = self.orig_i18n_dir
class TestTWTranslate(TestTWN):
--
To view, visit
https://gerrit.wikimedia.org/r/137924
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie4f77a8ace594619fee98996cc4403915316b51b
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot <>