# Path: stestr/commands/list.py
# class List(command.Command):
#     def get_parser(self, prog_name):
#     def take_action(self, parsed_args):
# def list_command(config='.stestr.conf', repo_type='file', repo_url=None,
#                  test_path=None, top_dir=None, group_regex=None,
#                  exclude_list=None,
#                  include_list=None,
#                  exclude_regex=None, filters=None,
#                  stdout=sys.stdout):
# 
# Path: stestr/commands/run.py
# def _to_int(possible, default=0, out=sys.stderr):
#     def get_parser(self, prog_name):
#     def take_action(self, parsed_args):
# def _find_failing(repo):
#     def gather_errors(test_dict):
# def run_command(config='.stestr.conf', repo_type='file',
#                 repo_url=None, test_path=None, top_dir=None, group_regex=None,
#                 failing=False, serial=False, concurrency=0, load_list=None,
#                 subunit_out=False, until_failure=False,
#                 analyze_isolation=False, isolated=False, worker_path=None,
#                 exclude_list=None,
#                 include_list=None,
#                 exclude_regex=None, no_discover=False,
#                 random=False, combine=False, filters=None, pretty_out=True,
#                 color=False, stdout=sys.stdout, abbreviate=False,
#                 suppress_attachments=False, all_attachments=False,
#                 show_binary_attachments=True, pdb=False):
#         def run_tests():
# def _run_tests(cmd, until_failure,
#                subunit_out=False, combine_id=None, repo_type='file',
#                repo_url=None, pretty_out=True, color=False, stdout=sys.stdout,
#                abbreviate=False, suppress_attachments=False,
#                all_attachments=False, show_binary_attachments=False):
#         def run_tests():
# class Run(command.Command):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


import functools
import io
import os
import re
import shutil
import subprocess
import tempfile
import fixtures
import subunit as subunit_lib
import testtools
from stestr.commands import list as list_cmd
from stestr.commands import run
from stestr.tests import base
        shutil.copy('stestr/tests/files/passing-tests', self.passing_file)
        shutil.copy('stestr/tests/files/failing-tests', self.failing_file)
        shutil.copy('setup.py', self.setup_py)
        shutil.copy('stestr/tests/files/setup.cfg', self.setup_cfg_file)
        shutil.copy('stestr/tests/files/__init__.py', self.init_file)
        shutil.copy('stestr/tests/files/stestr.yaml', self.user_config)

        self.stdout = io.StringIO()
        self.stderr = io.StringIO()
        # Change directory, run wrapper and check result
        self.addCleanup(os.chdir, self.repo_root)
        os.chdir(self.directory)
        subprocess.call('stestr init', shell=True)

    def _check_subunit(self, output_stream):
        stream = subunit_lib.ByteStreamToStreamResult(output_stream)
        starts = testtools.StreamResult()
        summary = testtools.StreamSummary()
        tests = []

        def _add_dict(test):
            tests.append(test)

        outcomes = testtools.StreamToDict(functools.partial(_add_dict))
        result = testtools.CopyStreamResult([starts, outcomes, summary])
        result.startTestRun()
        try:
            stream.run(result)
        finally:
            result.stopTestRun()

# Path: stestr/commands/list.py
# class List(command.Command):
#     def get_parser(self, prog_name):
#     def take_action(self, parsed_args):
# def list_command(config='.stestr.conf', repo_type='file', repo_url=None,
#                  test_path=None, top_dir=None, group_regex=None,
#                  exclude_list=None,
#                  include_list=None,
#                  exclude_regex=None, filters=None,
#                  stdout=sys.stdout):
# 
# Path: stestr/commands/run.py
# def _to_int(possible, default=0, out=sys.stderr):
#     def get_parser(self, prog_name):
#     def take_action(self, parsed_args):
# def _find_failing(repo):
#     def gather_errors(test_dict):
# def run_command(config='.stestr.conf', repo_type='file',
#                 repo_url=None, test_path=None, top_dir=None, group_regex=None,
#                 failing=False, serial=False, concurrency=0, load_list=None,
#                 subunit_out=False, until_failure=False,
#                 analyze_isolation=False, isolated=False, worker_path=None,
#                 exclude_list=None,
#                 include_list=None,
#                 exclude_regex=None, no_discover=False,
#                 random=False, combine=False, filters=None, pretty_out=True,
#                 color=False, stdout=sys.stdout, abbreviate=False,
#                 suppress_attachments=False, all_attachments=False,
#                 show_binary_attachments=True, pdb=False):
#         def run_tests():
# def _run_tests(cmd, until_failure,
#                subunit_out=False, combine_id=None, repo_type='file',
#                repo_url=None, pretty_out=True, color=False, stdout=sys.stdout,
#                abbreviate=False, suppress_attachments=False,
#                all_attachments=False, show_binary_attachments=False):
#         def run_tests():
# class Run(command.Command):
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


# Path: stestr/tests/test_return_codes.py
import functools
import io
import os
import re
import shutil
import subprocess
import tempfile
import fixtures
import subunit as subunit_lib
import testtools
from stestr.commands import list as list_cmd
from stestr.commands import run
from stestr.tests import base

        shutil.copy('stestr/tests/files/passing-tests', self.passing_file)
        shutil.copy('stestr/tests/files/failing-tests', self.failing_file)
        shutil.copy('setup.py', self.setup_py)
        shutil.copy('stestr/tests/files/setup.cfg', self.setup_cfg_file)
        shutil.copy('stestr/tests/files/__init__.py', self.init_file)
        shutil.copy('stestr/tests/files/stestr.yaml', self.user_config)

        self.stdout = io.StringIO()
        self.stderr = io.StringIO()
        # Change directory, run wrapper and check result
        self.addCleanup(os.chdir, self.repo_root)
        os.chdir(self.directory)
        subprocess.call('stestr init', shell=True)

    def _check_subunit(self, output_stream):
        stream = subunit_lib.ByteStreamToStreamResult(output_stream)
        starts = testtools.StreamResult()
        summary = testtools.StreamSummary()
        tests = []

        def _add_dict(test):
            tests.append(test)

        outcomes = testtools.StreamToDict(functools.partial(_add_dict))
        result = testtools.CopyStreamResult([starts, outcomes, summary])
        result.startTestRun()
        try:
            stream.run(result)
        finally:
            result.stopTestRun()

        self.assertThat(len(tests), testtools.matchers.GreaterThan(0))