# Path: stestr/commands/load.py
# def load(force_init=False, in_streams=None,
#          subunit_out=False, repo_type='file', repo_url=None,
#          run_id=None, streams=None, pretty_out=False, color=False,
#          stdout=sys.stdout, abbreviate=False, suppress_attachments=False,
#          serial=False, all_attachments=False, show_binary_attachments=False):
#     """Load subunit streams into a repository
# 
#     This function will load subunit streams into the repository. It will
#     output to STDOUT the results from the input stream. Internally this is
#     used by the run command to both output the results as well as store the
#     result in the repository.
# 
#     :param bool force_init: Initialize the specified repository if it hasn't
#         been created.
#     :param list in_streams: A list of file objects that will be saved into the
#         repository
#     :param bool subunit_out: Output the subunit stream to stdout
#     :param str repo_type: This is the type of repository to use. Valid choices
#         are 'file' and 'sql'.
#     :param str repo_url: The url of the repository to use.
#     :param run_id: The optional run id to save the subunit stream to.
#     :param list streams: A list of file paths to read for the input streams.
#     :param bool pretty_out: Use the subunit-trace output filter for the loaded
#         stream.
#     :param bool color: Enabled colorized subunit-trace output
#     :param file stdout: The output file to write all output to. By default
#         this is sys.stdout
#     :param bool abbreviate: Use abbreviated output if set true
#     :param bool suppress_attachments: When set true attachments subunit_trace
#         will not print attachments on successful test execution.
#     :param bool all_attachments: When set true subunit_trace will print all
#         text attachments on successful test execution.
#     :param bool show_binary_attachments: When set to true, subunit_trace will
#         print binary attachments in addition to text attachments.
# 
#     :return return_code: The exit code for the command. 0 for success and > 0
#         for failures.
#     :rtype: int
#     """
#     try:
#         repo = util.get_repo_open(repo_type, repo_url)
#     except repository.RepositoryNotFound:
#         if force_init:
#             try:
#                 repo = util.get_repo_initialise(repo_type, repo_url)
#             except OSError as e:
#                 if e.errno != errno.EEXIST:
#                     raise
#                 repo_path = repo_url or './stestr'
#                 stdout.write('The specified repository directory %s already '
#                              'exists. Please check if the repository already '
#                              'exists or select a different path\n'
#                              % repo_path)
#                 exit(1)
#         else:
#             raise
#     # Not a full implementation of TestCase, but we only need to iterate
#     # back to it. Needs to be a callable - its a head fake for
#     # testsuite.add.
#     if in_streams:
#         streams = utils.iter_streams(in_streams, 'subunit')
#     elif streams:
#         opener = functools.partial(open, mode='rb')
#         streams = map(opener, streams)
#     else:
#         streams = [sys.stdin]
# 
#     def mktagger(pos, result):
#         return testtools.StreamTagger([result], add=['worker-%d' % pos])
# 
#     def make_tests():
#         for pos, stream in enumerate(streams):
#             # Calls StreamResult API.
#             case = subunit.ByteStreamToStreamResult(
#                 stream, non_subunit_name='stdout')
#             decorate = functools.partial(mktagger, pos)
#             case = testtools.DecorateTestCaseResult(case, decorate)
#             yield (case, str(pos))
#     if not run_id:
#         inserter = repo.get_inserter()
#     else:
#         inserter = repo.get_inserter(run_id=run_id)
# 
#     retval = 0
#     if serial:
#         for stream in streams:
#             # Calls StreamResult API.
#             case = subunit.ByteStreamToStreamResult(
#                 stream, non_subunit_name='stdout')
#             result = _load_case(inserter, repo, case, subunit_out, pretty_out,
#                                 color, stdout, abbreviate,
#                                 suppress_attachments, all_attachments,
#                                 show_binary_attachments)
#             if result or retval:
#                 retval = 1
#             else:
#                 retval = 0
#     else:
#         case = testtools.ConcurrentStreamTestSuite(make_tests)
#         retval = _load_case(inserter, repo, case, subunit_out, pretty_out,
#                             color, stdout, abbreviate, suppress_attachments,
#                             all_attachments, show_binary_attachments)
# 
#     return retval
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


import io
from stestr.commands import load
from stestr.tests import base
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.




class TestLoadCommand(base.TestCase):
    def test_empty_with_pretty_out(self):
        stream = io.BytesIO()
        output = io.BytesIO()

# Path: stestr/commands/load.py
# def load(force_init=False, in_streams=None,
#          subunit_out=False, repo_type='file', repo_url=None,
#          run_id=None, streams=None, pretty_out=False, color=False,
#          stdout=sys.stdout, abbreviate=False, suppress_attachments=False,
#          serial=False, all_attachments=False, show_binary_attachments=False):
#     """Load subunit streams into a repository
# 
#     This function will load subunit streams into the repository. It will
#     output to STDOUT the results from the input stream. Internally this is
#     used by the run command to both output the results as well as store the
#     result in the repository.
# 
#     :param bool force_init: Initialize the specified repository if it hasn't
#         been created.
#     :param list in_streams: A list of file objects that will be saved into the
#         repository
#     :param bool subunit_out: Output the subunit stream to stdout
#     :param str repo_type: This is the type of repository to use. Valid choices
#         are 'file' and 'sql'.
#     :param str repo_url: The url of the repository to use.
#     :param run_id: The optional run id to save the subunit stream to.
#     :param list streams: A list of file paths to read for the input streams.
#     :param bool pretty_out: Use the subunit-trace output filter for the loaded
#         stream.
#     :param bool color: Enabled colorized subunit-trace output
#     :param file stdout: The output file to write all output to. By default
#         this is sys.stdout
#     :param bool abbreviate: Use abbreviated output if set true
#     :param bool suppress_attachments: When set true attachments subunit_trace
#         will not print attachments on successful test execution.
#     :param bool all_attachments: When set true subunit_trace will print all
#         text attachments on successful test execution.
#     :param bool show_binary_attachments: When set to true, subunit_trace will
#         print binary attachments in addition to text attachments.
# 
#     :return return_code: The exit code for the command. 0 for success and > 0
#         for failures.
#     :rtype: int
#     """
#     try:
#         repo = util.get_repo_open(repo_type, repo_url)
#     except repository.RepositoryNotFound:
#         if force_init:
#             try:
#                 repo = util.get_repo_initialise(repo_type, repo_url)
#             except OSError as e:
#                 if e.errno != errno.EEXIST:
#                     raise
#                 repo_path = repo_url or './stestr'
#                 stdout.write('The specified repository directory %s already '
#                              'exists. Please check if the repository already '
#                              'exists or select a different path\n'
#                              % repo_path)
#                 exit(1)
#         else:
#             raise
#     # Not a full implementation of TestCase, but we only need to iterate
#     # back to it. Needs to be a callable - its a head fake for
#     # testsuite.add.
#     if in_streams:
#         streams = utils.iter_streams(in_streams, 'subunit')
#     elif streams:
#         opener = functools.partial(open, mode='rb')
#         streams = map(opener, streams)
#     else:
#         streams = [sys.stdin]
# 
#     def mktagger(pos, result):
#         return testtools.StreamTagger([result], add=['worker-%d' % pos])
# 
#     def make_tests():
#         for pos, stream in enumerate(streams):
#             # Calls StreamResult API.
#             case = subunit.ByteStreamToStreamResult(
#                 stream, non_subunit_name='stdout')
#             decorate = functools.partial(mktagger, pos)
#             case = testtools.DecorateTestCaseResult(case, decorate)
#             yield (case, str(pos))
#     if not run_id:
#         inserter = repo.get_inserter()
#     else:
#         inserter = repo.get_inserter(run_id=run_id)
# 
#     retval = 0
#     if serial:
#         for stream in streams:
#             # Calls StreamResult API.
#             case = subunit.ByteStreamToStreamResult(
#                 stream, non_subunit_name='stdout')
#             result = _load_case(inserter, repo, case, subunit_out, pretty_out,
#                                 color, stdout, abbreviate,
#                                 suppress_attachments, all_attachments,
#                                 show_binary_attachments)
#             if result or retval:
#                 retval = 1
#             else:
#                 retval = 0
#     else:
#         case = testtools.ConcurrentStreamTestSuite(make_tests)
#         retval = _load_case(inserter, repo, case, subunit_out, pretty_out,
#                             color, stdout, abbreviate, suppress_attachments,
#                             all_attachments, show_binary_attachments)
# 
#     return retval
# 
# Path: stestr/tests/base.py
# class TestCase(testtools.TestCase):
#     def setUp(self):


# Path: stestr/tests/test_load.py
import io
from stestr.commands import load
from stestr.tests import base

# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.




class TestLoadCommand(base.TestCase):
    def test_empty_with_pretty_out(self):
        stream = io.BytesIO()
        output = io.BytesIO()

        res = load.load(in_streams=[('subunit', stream)], pretty_out=True,