# Path: stestr/subunit_runner/program.py
# def filter_by_ids(suite_or_case, test_ids):
# def iterate_tests(test_suite_or_case):
# def list_test(test):
#     def __init__(self, module='__main__', defaultTest=None, argv=None,
#                  testRunner=None, testLoader=unittest.defaultTestLoader,
#                  exit=False, verbosity=1, failfast=None, catchbreak=None,
#                  buffer=None, warnings=None, tb_locals=False):
#     def _getParentArgParser(self):
#     def _get_runner(self):
#     def runTests(self):
# class TestProgram(unittest.TestProgram):


from functools import partial
from subunit import StreamResultToBytes
from subunit.test_results import AutoTimingTestResultDecorator
from testtools import ExtendedToStreamDecorator
from stestr.subunit_runner import program
import os
import sys
    def list(self, test, loader=None):
        "List the test."
        result, errors = self._list(test)
        if loader is not None:
            errors = loader.errors
        if errors:
            failed_descr = '\n'.join(errors).encode('utf8')
            result.status(file_name="import errors", runnable=False,
                          file_bytes=failed_descr,
                          mime_type="text/plain;charset=utf8")
            sys.exit(2)

    def _list(self, test):
        test_ids, errors = program.list_test(test)
        try:
            fileno = self.stream.fileno()
        except Exception:
            fileno = None
        if fileno is not None:
            stream = os.fdopen(fileno, 'wb', 0)
        else:
            stream = self.stream
        result = StreamResultToBytes(stream)
        for test_id in test_ids:
            result.status(test_id=test_id, test_status='exists')
        return result, errors


def main():
    runner = SubunitTestRunner

# Path: stestr/subunit_runner/program.py
# def filter_by_ids(suite_or_case, test_ids):
# def iterate_tests(test_suite_or_case):
# def list_test(test):
#     def __init__(self, module='__main__', defaultTest=None, argv=None,
#                  testRunner=None, testLoader=unittest.defaultTestLoader,
#                  exit=False, verbosity=1, failfast=None, catchbreak=None,
#                  buffer=None, warnings=None, tb_locals=False):
#     def _getParentArgParser(self):
#     def _get_runner(self):
#     def runTests(self):
# class TestProgram(unittest.TestProgram):


# Path: stestr/subunit_runner/run.py
from functools import partial
from subunit import StreamResultToBytes
from subunit.test_results import AutoTimingTestResultDecorator
from testtools import ExtendedToStreamDecorator
from stestr.subunit_runner import program
import os
import sys

    def list(self, test, loader=None):
        "List the test."
        result, errors = self._list(test)
        if loader is not None:
            errors = loader.errors
        if errors:
            failed_descr = '\n'.join(errors).encode('utf8')
            result.status(file_name="import errors", runnable=False,
                          file_bytes=failed_descr,
                          mime_type="text/plain;charset=utf8")
            sys.exit(2)

    def _list(self, test):
        test_ids, errors = program.list_test(test)
        try:
            fileno = self.stream.fileno()
        except Exception:
            fileno = None
        if fileno is not None:
            stream = os.fdopen(fileno, 'wb', 0)
        else:
            stream = self.stream
        result = StreamResultToBytes(stream)
        for test_id in test_ids:
            result.status(test_id=test_id, test_status='exists')
        return result, errors


def main():
    runner = SubunitTestRunner

    program.TestProgram(