Mercurial > hgsubversion
changeset 645:3cb5042531fb
tests: verify locations of any imported hgsubversion modules
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Wed, 14 Jul 2010 15:39:24 +0200 |
parents | 95abc4cfc78f |
children | f12257bf8b91 |
files | tests/test_util.py |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_util.py +++ b/tests/test_util.py @@ -142,9 +142,29 @@ def rmtree(path): os.chmod(f, s.st_mode | stat.S_IWRITE) shutil.rmtree(path) +def _verify_our_modules(): + ''' + Verify that hgsubversion was imported from the correct location. + + The correct location is any location within the parent directory of the + directory containing this file. + ''' + + for modname, module in sys.modules.iteritems(): + if not module or not modname.startswith('hgsubversion.'): + continue + + modloc = module.__file__ + cp = os.path.commonprefix((os.path.abspath(__file__), modloc)) + assert cp.rstrip(os.sep) == _rootdir, ( + 'Module location verification failed: hgsubversion was imported ' + 'from the wrong path!' + ) class TestBase(unittest.TestCase): def setUp(self): + _verify_our_modules() + self.oldenv = dict([(k, os.environ.get(k, None), ) for k in ('LANG', 'LC_ALL', 'HGRCPATH', )]) self.oldt = i18n.t @@ -182,6 +202,8 @@ class TestBase(unittest.TestCase): os.chdir(self.oldwd) setattr(ui.ui, self.patch[0].func_name, self.patch[0]) + _verify_our_modules() + def assertStringEqual(self, l, r): try: self.assertEqual(l, r, 'failed string equality check, see stdout for details')