# HG changeset patch # User Siddharth Agarwal # Date 1413324744 14400 # Node ID 260212f056b738d32dcda92bda4554d0b7efb484 # Parent 012965ab3bf7540c3d9158d6e9cd54d57b36a4a3 test_util: fix up i18n monkeypatch for Mercurial 3.2 Mercurial rev 0d0350cfc7ab changed the API a bit. diff --git a/tests/test_util.py b/tests/test_util.py --- a/tests/test_util.py +++ b/tests/test_util.py @@ -24,7 +24,7 @@ from mercurial import i18n from mercurial import node from mercurial import scmutil from mercurial import ui -from mercurial import util +from mercurial import util as hgutil from mercurial import extensions from hgsubversion import compathacks @@ -454,9 +454,15 @@ class TestBase(unittest.TestCase): self.oldenv = dict([(k, os.environ.get(k, None),) for k in ('LANG', 'LC_ALL', 'HGRCPATH',)]) - self.oldt = i18n.t - os.environ['LANG'] = os.environ['LC_ALL'] = 'C' - i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) + try: + self.oldugettext = i18n._ugettext # Mercurial >= 3.2 + except AttributeError: + self.oldt = i18n.t + os.environ['LANG'] = os.environ['LC_ALL'] = 'C' + i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) + else: + os.environ['LANG'] = os.environ['LC_ALL'] = 'C' + i18n.setdatapath(hgutil.datapath) self.oldwd = os.getcwd() self.tmpdir = tempfile.mkdtemp( @@ -503,7 +509,10 @@ class TestBase(unittest.TestCase): del os.environ[var] else: os.environ[var] = val - i18n.t = self.oldt + try: + i18n._ugettext = self.oldugettext # Mercurial >= 3.2 + except AttributeError: + i18n.t = self.oldt rmtree(self.tmpdir) os.chdir(self.oldwd) setattr(ui.ui, self.patch[0].func_name, self.patch[0])