'Locate a Cactus executable and ensure that it\'ll run using the right interpreter.
This is meant to work well in a Tox environment. That\'s how we run our tests, so that\'s all that really
matters here.'

def find_cactus(self):

    bin_path = os.path.abspath(os.path.dirname(sys.executable))
    try:
        path = os.path.join(bin_path, 'cactus')
        with open(path) as f:
            self.assertEqual('#!{0}'.format(sys.executable), f.readline().strip())
    except IOError:
        pass
    else:
        return path
    try:
        path = os.path.join(bin_path, 'cactus.exe')
        with open(path):
            pass
    except IOError:
        pass
    else:
        return path
    self.fail('Unable    to    find    Cactus')
