Mercurial > python-hglib
diff tests/with_hg.py @ 75:f4f636ecca3e
tests: add a nose plugin that allows specifying a custom hg to run tests
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Sat, 15 Oct 2011 20:03:04 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/with_hg.py Sat Oct 15 20:03:04 2011 +0200 @@ -0,0 +1,33 @@ +import os +from nose.plugins import Plugin + +class WithHgPlugin(Plugin): + name = 'with-hg' + enabled = False + + def options(self, parser, env): + Plugin.options(self, parser, env) + parser.add_option('--with-hg', + action='store', + type='string', + metavar='HG', + dest='with_hg', + help='test using specified hg script.') + + def configure(self, options, conf): + Plugin.configure(self, options, conf) + if options.with_hg: + self.enabled = True + self.hgpath = os.path.realpath(options.with_hg) + + def begin(self): + import hglib + + p = hglib.util.popen([self.hgpath, 'version']) + p.communicate() + + if p.returncode: + raise ValueError("custom hg %r doesn't look like Mercurial" + % self.hgpath) + + hglib.HGPATH = self.hgpath