'Run the given test case or test suite.'

def run(self, test):

    class_ = test.__class__
    classname = ((class_.__module__ + '.') + class_.__name__)
    if (self._stream == None):
        filename = ('TEST-%s.xml' % classname)
        stream = file(os.path.join(self._path, filename), 'w')
        stream.write('<?xml    version="1.0"    encoding="utf-8"?>\n')
    else:
        stream = self._stream
    result = _XMLTestResult(classname)
    start_time = time.time()
    old_stdout = sys.stdout
    old_stderr = sys.stderr
    sys.stdout = StringIO()
    sys.stderr = StringIO()
    try:
        test(result)
        try:
            out_s = sys.stdout.getvalue()
        except AttributeError:
            out_s = ''
        try:
            err_s = sys.stderr.getvalue()
        except AttributeError:
            err_s = ''
    finally:
        sys.stdout = old_stdout
        sys.stderr = old_stderr
    time_taken = (time.time() - start_time)
    result.print_report(stream, time_taken, out_s, err_s)
    result.print_report_text(sys.stdout, time_taken, out_s, err_s)
    return result
