view tests/with_hg.py @ 186:d06b48001662

package: update package url Replace the package url which was pointing to the repository to the wiki page instead. This way pypi users will directly see the basic usage and can easily find the repository url on the wiki page.
author Boris Feld <boris.feld@octobus.net>
date Wed, 19 Jul 2017 14:48:40 +0200
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