'assert that the given output string is equal to a in-tree stub file,
if a test needs to check multiple outputs it can use custom ext\'s'

def assertOutputStub(self, output, ext='stub', builder_id='(not    assigned)'):

    filepath = os.path.abspath(os.path.join(os.path.dirname(__file__), self.id().split('.')[(-1)]))
    print filepath
    filepath = ('%s.%s' % (filepath, ext))
    try:
        with open(filepath, 'r') as f:
            stub = f.read()
    except (IOError, OSError) as e:
        if (e.errno == errno.ENOENT):
            self.fail(('%r    does    not    exist' % filepath))
        else:
            self.fail(('%r    could    not    be    read    (%s)' % (filepath, e)))
    output = output.replace(self.tempfile, '__RINGFILE__')
    stub = stub.replace('__BUILDER_ID__', builder_id)
    for (i, (value, expected)) in enumerate(itertools.izip_longest(output.splitlines(), stub.splitlines())):
        value = (value or '').rstrip()
        expected = (expected or '').rstrip()
        try:
            self.assertEqual(value, expected)
        except AssertionError:
            msg = ('Line    #%s    value    is    not    like    expected:\n%r\n%r' % (i, value, expected))
            msg += '\n\nFull    output    was:\n'
            for (i, line) in enumerate(output.splitlines()):
                msg += ('%3d:    %s\n' % (i, line))
            msg += '\n\nCompared    to    stub:\n'
            for (i, line) in enumerate(stub.splitlines()):
                msg += ('%3d:    %s\n' % (i, line))
            self.fail(msg)
