Mercurial > hgsubversion
comparison tests/test_util.py @ 486:5607e81ba616
test_util: specify LANG=LC_ALL=C so l10n stops breaking tests
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Tue, 15 Sep 2009 22:33:41 -0400 |
parents | 37718f514acb |
children | 6b481331c355 |
comparison
equal
deleted
inserted
replaced
485:c07bcdc6e1bd | 486:5607e81ba616 |
---|---|
1 import gettext | |
1 import errno | 2 import errno |
2 import imp | 3 import imp |
3 import os | 4 import os |
4 import subprocess | 5 import subprocess |
5 import shutil | 6 import shutil |
14 from mercurial import context | 15 from mercurial import context |
15 from mercurial import commands | 16 from mercurial import commands |
16 from mercurial import hg | 17 from mercurial import hg |
17 from mercurial import node | 18 from mercurial import node |
18 from mercurial import ui | 19 from mercurial import ui |
20 from mercurial import i18n | |
19 | 21 |
20 from hgsubversion import util | 22 from hgsubversion import util |
21 | 23 |
22 import sys | 24 import sys |
23 # Documentation for Subprocess.Popen() says: | 25 # Documentation for Subprocess.Popen() says: |
126 raise | 128 raise |
127 if (s.st_mode & stat.S_IWRITE) == 0: | 129 if (s.st_mode & stat.S_IWRITE) == 0: |
128 os.chmod(f, s.st_mode | stat.S_IWRITE) | 130 os.chmod(f, s.st_mode | stat.S_IWRITE) |
129 shutil.rmtree(path) | 131 shutil.rmtree(path) |
130 | 132 |
133 | |
131 class TestBase(unittest.TestCase): | 134 class TestBase(unittest.TestCase): |
132 def setUp(self): | 135 def setUp(self): |
136 self.oldenv = dict([(k, os.environ.get(k, None), ) for k in | |
137 ('LANG', 'LC_ALL', 'HGRCPATH', )]) | |
138 self.oldt = i18n.t | |
139 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' | |
140 i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) | |
141 | |
133 self.oldwd = os.getcwd() | 142 self.oldwd = os.getcwd() |
134 self.tmpdir = tempfile.mkdtemp( | 143 self.tmpdir = tempfile.mkdtemp( |
135 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None)) | 144 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None)) |
136 self.hgrc = os.path.join(self.tmpdir, '.hgrc') | 145 self.hgrc = os.path.join(self.tmpdir, '.hgrc') |
137 os.environ['HGRCPATH'] = self.hgrc | 146 os.environ['HGRCPATH'] = self.hgrc |
149 # setups. | 158 # setups. |
150 self.patch = (ui.ui.write_err, ui.ui.write) | 159 self.patch = (ui.ui.write_err, ui.ui.write) |
151 setattr(ui.ui, self.patch[0].func_name, self.patch[1]) | 160 setattr(ui.ui, self.patch[0].func_name, self.patch[1]) |
152 | 161 |
153 def tearDown(self): | 162 def tearDown(self): |
163 for var, val in self.oldenv.iteritems(): | |
164 if val is None: | |
165 del os.environ[var] | |
166 else: | |
167 os.environ[var] = val | |
168 i18n.t = self.oldt | |
154 rmtree(self.tmpdir) | 169 rmtree(self.tmpdir) |
155 os.chdir(self.oldwd) | 170 os.chdir(self.oldwd) |
156 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) | 171 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) |
157 | 172 |
158 def _load_fixture_and_fetch(self, fixture_name, subdir='', stupid=False): | 173 def _load_fixture_and_fetch(self, fixture_name, subdir='', stupid=False): |