Mercurial > python-hglib
view tests/with_hg.py @ 197:6949fc164439 2.5
hgclient: look for an open server before closing it in ResponseError block
At least some of the codepaths that can throw a ResponseError close
the server first (the one in _readchannel does so in order to detect
server startup failures, for example), so we have to verify we have a
server to close before doing so, otherwise we can lose the
ResponseError and the user sees an AttributeError when we try to use
.close() on a NoneType.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 10 Dec 2017 12:52:37 -0500 |
parents | f4f636ecca3e |
children |
line wrap: on
line source
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