Mercurial > hgsubversion
diff tests/test_util.py @ 334:3c3c3264c362
test_util: Make the patching of ui.ui.write_err() slightly more reusable.
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Tue, 12 May 2009 20:14:15 +0200 |
parents | a59ab58969d9 |
children | 46e69be8e2c8 |
line wrap: on
line diff
--- a/tests/test_util.py +++ b/tests/test_util.py @@ -81,7 +81,8 @@ class TestBase(unittest.TestCase): self.hgrc = os.path.join(self.tmpdir, '.hgrc') os.environ['HGRCPATH'] = self.hgrc rc = open(self.hgrc, 'w') - rc.write('[extensions]\nhgsubversion=') + for l in '[extensions]', 'hgsubversion=': + print >> rc, l self.repo_path = '%s/testrepo' % self.tmpdir self.wc_path = '%s/testrepo_wc' % self.tmpdir @@ -91,13 +92,13 @@ class TestBase(unittest.TestCase): # instead. Using the regular UI class, with all stderr redirected to # stdout ensures that the test setup is much more similar to usage # setups. - self._ui_write_err = ui.ui.write_err - ui.ui.write_err = ui.ui.write + self.patch = (ui.ui.write_err, ui.ui.write) + setattr(ui.ui, self.patch[0].func_name, self.patch[1]) def tearDown(self): rmtree(self.tmpdir) os.chdir(self.oldwd) - ui.ui.write_err = self._ui_write_err + setattr(ui.ui, self.patch[0].func_name, self.patch[0]) def _load_fixture_and_fetch(self, fixture_name, subdir='', stupid=False): return load_fixture_and_fetch(fixture_name, self.repo_path,