# Path: stestr/output.py
# def output_table(table, output=sys.stdout):
#     def show_row(row):
# def output_tests(tests, output=sys.stdout):
# def make_result(get_id, output=sys.stdout):
# def output_summary(successful, tests, tests_delta, time, time_delta, values,
#                    output=sys.stdout):
# def output_stream(stream, output=sys.stdout):
#     def __init__(self, process):
#     def _append_return_code_as_test(self):
#     def read(self, count=-1):
#     def readline(self):
#     def readlines(self):
# class ReturnCodeToSubunit:
# 
# Path: stestr/repository/abstract.py
# class AbstractRepositoryFactory:
# class AbstractRepository:
# class AbstractTestRun:
# class RepositoryNotFound(Exception):
#     def initialise(self, url):
#     def open(self, url):
#     def count(self):
#     def get_failing(self):
#     def get_run_ids(self):
#     def remove_run_id(self, run_id):
#     def get_inserter(self, partial=False, run_id=None, metadata=None):
#     def _get_inserter(self, partial=False, run_id=None, metadata=None):
#     def get_latest_run(self):
#     def get_test_run(self, run_id):
#     def get_test_times(self, test_ids):
#     def _get_test_times(self, test_ids):
#     def latest_id(self):
#     def get_test_ids(self, run_id):
#         def gather(test_dict):
#     def find_metadata(self, metadata):
#     def get_id(self):
#     def get_subunit_stream(self):
#     def get_test(self):
#     def get_metadata(self):
#     def __init__(self, url):
# 
# Path: stestr/repository/util.py
# def _get_default_repo_url(repo_type):
# def get_repo_open(repo_type, repo_url=None):
# def get_repo_initialise(repo_type, repo_url=None):
# 
# Path: stestr/results.py
# def wasSuccessful(summary):
#     def __init__(self):
#     def startTestRun(self):
#     def status(self, *args, **kwargs):
#     def get_num_failures(self):
#     def get_time_taken(self):
#     def __init__(self, byte_stream):
#     def status(self, test_id=None, test_status=None, test_tags=None,
#                runnable=True, file_name=None, file_bytes=None, eof=False,
#                mime_type=None, route_code=None, timestamp=None):
#     def __init__(self, get_id, stream, previous_run=None):
#     def _format_error(self, label, test, error_text, test_tags=None):
#     def status(self, **kwargs):
#     def _get_previous_summary(self):
#     def _output_summary(self, run_id):
#     def startTestRun(self):
#     def stopTestRun(self):
#     def get_summary(self):
# class SummarizingResult(testtools.StreamSummary):
# class CatFiles(testtools.StreamResult):
# class CLITestResult(testtools.StreamResult):
# 
# Path: stestr/subunit_trace.py
# DAY_SECONDS = 60 * 60 * 24
# FAILS = []
# RESULTS = {}
# def total_seconds(timedelta):
# def cleanup_test_name(name, strip_tags=True, strip_scenarios=False):
# def get_duration(timestamps):
# def find_worker(test):
# def print_attachments(stream, test, all_channels=False,
#                       show_binary_attachments=False):
# def find_test_run_time_diff(test_id, run_time):
# def show_outcome(stream, test, print_failures=False, failonly=False,
#                  enable_diff=False, threshold='0', abbreviate=False,
#                  enable_color=False, suppress_attachments=False,
#                  all_attachments=False, show_binary_attachments=True):
# def print_fails(stream):
# def count_tests(key, value):
# def get_stuck_in_progress():
# def run_time():
# def worker_stats(worker):
# def print_summary(stream, elapsed_time):
# def parse_args():
# def trace(stdin, stdout, print_failures=False, failonly=False,
#           enable_diff=False, abbreviate=False, color=False, post_fails=False,
#           no_summary=False, suppress_attachments=False, all_attachments=False,
#           show_binary_attachments=False):
# def main():
# 
# Path: stestr/user_config.py
# def get_user_config(path=None):
#     def __init__(self, path):
#     def run(self):
#     def failing(self):
#     def last(self):
#     def load(self):
#     def history_list(self):
#     def history_show(self):
# class UserConfig:


import functools
import sys
import subunit
import testtools
from cliff import command
from cliff import lister
from stestr import output
from stestr.repository import abstract
from stestr.repository import util
from stestr import results
from stestr import subunit_trace
from stestr import user_config
        stream = run.get_subunit_stream()
        output.output_stream(stream, output=stdout)
        # Exits 0 if we successfully wrote the stream.
        return 0
    case = run.get_test()
    try:
        if repo_type == 'file':
            if run_id:
                previous_run = int(run_id) - 1
            else:
                previous_run = repo.get_test_run(repo.latest_id() - 1)
        # TODO(mtreinish): add a repository api to get the previous_run to
        # unify this logic
        else:
            previous_run = None
    except KeyError:
        previous_run = None
    failed = False
    if not pretty_out:
        output_result = results.CLITestResult(run.get_id, stdout,
                                              previous_run)
        summary = output_result.get_summary()
        output_result.startTestRun()
        try:
            case.run(output_result)
        finally:
            output_result.stopTestRun()
        failed = not results.wasSuccessful(summary)
    else:
        stream = run.get_subunit_stream()

# Path: stestr/output.py
# def output_table(table, output=sys.stdout):
#     def show_row(row):
# def output_tests(tests, output=sys.stdout):
# def make_result(get_id, output=sys.stdout):
# def output_summary(successful, tests, tests_delta, time, time_delta, values,
#                    output=sys.stdout):
# def output_stream(stream, output=sys.stdout):
#     def __init__(self, process):
#     def _append_return_code_as_test(self):
#     def read(self, count=-1):
#     def readline(self):
#     def readlines(self):
# class ReturnCodeToSubunit:
# 
# Path: stestr/repository/abstract.py
# class AbstractRepositoryFactory:
# class AbstractRepository:
# class AbstractTestRun:
# class RepositoryNotFound(Exception):
#     def initialise(self, url):
#     def open(self, url):
#     def count(self):
#     def get_failing(self):
#     def get_run_ids(self):
#     def remove_run_id(self, run_id):
#     def get_inserter(self, partial=False, run_id=None, metadata=None):
#     def _get_inserter(self, partial=False, run_id=None, metadata=None):
#     def get_latest_run(self):
#     def get_test_run(self, run_id):
#     def get_test_times(self, test_ids):
#     def _get_test_times(self, test_ids):
#     def latest_id(self):
#     def get_test_ids(self, run_id):
#         def gather(test_dict):
#     def find_metadata(self, metadata):
#     def get_id(self):
#     def get_subunit_stream(self):
#     def get_test(self):
#     def get_metadata(self):
#     def __init__(self, url):
# 
# Path: stestr/repository/util.py
# def _get_default_repo_url(repo_type):
# def get_repo_open(repo_type, repo_url=None):
# def get_repo_initialise(repo_type, repo_url=None):
# 
# Path: stestr/results.py
# def wasSuccessful(summary):
#     def __init__(self):
#     def startTestRun(self):
#     def status(self, *args, **kwargs):
#     def get_num_failures(self):
#     def get_time_taken(self):
#     def __init__(self, byte_stream):
#     def status(self, test_id=None, test_status=None, test_tags=None,
#                runnable=True, file_name=None, file_bytes=None, eof=False,
#                mime_type=None, route_code=None, timestamp=None):
#     def __init__(self, get_id, stream, previous_run=None):
#     def _format_error(self, label, test, error_text, test_tags=None):
#     def status(self, **kwargs):
#     def _get_previous_summary(self):
#     def _output_summary(self, run_id):
#     def startTestRun(self):
#     def stopTestRun(self):
#     def get_summary(self):
# class SummarizingResult(testtools.StreamSummary):
# class CatFiles(testtools.StreamResult):
# class CLITestResult(testtools.StreamResult):
# 
# Path: stestr/subunit_trace.py
# DAY_SECONDS = 60 * 60 * 24
# FAILS = []
# RESULTS = {}
# def total_seconds(timedelta):
# def cleanup_test_name(name, strip_tags=True, strip_scenarios=False):
# def get_duration(timestamps):
# def find_worker(test):
# def print_attachments(stream, test, all_channels=False,
#                       show_binary_attachments=False):
# def find_test_run_time_diff(test_id, run_time):
# def show_outcome(stream, test, print_failures=False, failonly=False,
#                  enable_diff=False, threshold='0', abbreviate=False,
#                  enable_color=False, suppress_attachments=False,
#                  all_attachments=False, show_binary_attachments=True):
# def print_fails(stream):
# def count_tests(key, value):
# def get_stuck_in_progress():
# def run_time():
# def worker_stats(worker):
# def print_summary(stream, elapsed_time):
# def parse_args():
# def trace(stdin, stdout, print_failures=False, failonly=False,
#           enable_diff=False, abbreviate=False, color=False, post_fails=False,
#           no_summary=False, suppress_attachments=False, all_attachments=False,
#           show_binary_attachments=False):
# def main():
# 
# Path: stestr/user_config.py
# def get_user_config(path=None):
#     def __init__(self, path):
#     def run(self):
#     def failing(self):
#     def last(self):
#     def load(self):
#     def history_list(self):
#     def history_show(self):
# class UserConfig:


# Path: stestr/commands/history.py
import functools
import sys
import subunit
import testtools
from cliff import command
from cliff import lister
from stestr import output
from stestr.repository import abstract
from stestr.repository import util
from stestr import results
from stestr import subunit_trace
from stestr import user_config

        stream = run.get_subunit_stream()
        output.output_stream(stream, output=stdout)
        # Exits 0 if we successfully wrote the stream.
        return 0
    case = run.get_test()
    try:
        if repo_type == 'file':
            if run_id:
                previous_run = int(run_id) - 1
            else:
                previous_run = repo.get_test_run(repo.latest_id() - 1)
        # TODO(mtreinish): add a repository api to get the previous_run to
        # unify this logic
        else:
            previous_run = None
    except KeyError:
        previous_run = None
    failed = False
    if not pretty_out:
        output_result = results.CLITestResult(run.get_id, stdout,
                                              previous_run)
        summary = output_result.get_summary()
        output_result.startTestRun()
        try:
            case.run(output_result)
        finally:
            output_result.stopTestRun()
        failed = not results.wasSuccessful(summary)
    else:
        stream = run.get_subunit_stream()

        failed = subunit_trace.trace(