# Path: nimoy/runner/metadata.py
# class RunnerContext:
# 
#     def __init__(self, use_power_assertions: bool = False):
#         self.use_power_assertions = use_power_assertions
# 
# Path: nimoy/runner/spec_finder.py
# class Location:
#     def __init__(self, suggested_location):
# 
#         # Format may be:
#         # - some_spec.py
#         # - some_spec.py::SpecName
#         # - some_spec.py::feature_name
#         # - some_spec.py::SpecName::feature_name
#         split_suggested_location = suggested_location.split("::")
# 
#         # some_spec.py
#         if len(split_suggested_location) == 1:
#             self.spec_path = split_suggested_location[0]
# 
#         # some_spec.py::SpecName or some_spec.py::feature_name
#         if len(split_suggested_location) == 2:
#             self.spec_path = split_suggested_location[0]
# 
#             # some_spec.py::SpecName
#             if split_suggested_location[1][0].isupper():
#                 self.spec_name = split_suggested_location[1]
# 
#             # some_spec.py::feature_name
#             else:
#                 self.feature_name = split_suggested_location[1]
# 
#         # some_spec.py::SpecName::feature_name
#         if len(split_suggested_location) == 3:
#             self.spec_path = split_suggested_location[0]
#             self.spec_name = split_suggested_location[1]
#             self.feature_name = split_suggested_location[2]
# 
# Path: nimoy/runner/unittest_execution_framework.py
# class UnitTestExecutionFramework:
#     def __init__(self, stream=None):
#         self.suite = unittest.TestSuite()
#         self.stream = stream
# 
#     def append_test(self, test):
#         self.suite.addTest(test)
# 
#     def run(self):
#         return unittest.TextTestRunner(stream=self.stream, verbosity=2).run(self.suite)
# 
# Path: nimoy/spec_runner.py
# class SpecRunner:
#     def run(self, execution_framework):
#         parser = argparse.ArgumentParser(prog='nimoy', description='Run a suite of Nimoy specs.')
#         parser.add_argument('--power-assertions', metavar='P', type=bool, nargs=1, default=False,
#                             help="Should Nimoy evaluate comparison expressions using power assertions (beta)")
#         parser.add_argument('specs', metavar='S', type=str, nargs='*',
#                             help="""A path to a spec file to execute or a directory to scan for spec files.
#                                     When naming a file it is possible to select which spec or feature to run. some_spec.py[::SpecName[::feature_name]]
#                                     """)
# 
#         args = parser.parse_args()
# 
#         spec_locations = SpecRunner._find_specs(args)
#         spec_locations_and_contents = SpecRunner._read_specs(spec_locations)
#         return SpecRunner._run_on_contents(RunnerContext(use_power_assertions=args.power_assertions),
#                                            execution_framework, spec_locations_and_contents)
# 
#     @staticmethod
#     def _run_on_contents(runner_context: RunnerContext, execution_framework, spec_locations_and_contents):
#         specs = SpecRunner._load_specs(runner_context, spec_locations_and_contents)
#         return SpecRunner._execute_specs(execution_framework, specs)
# 
#     @staticmethod
#     def _find_specs(args):
#         return SpecFinder(os.getcwd()).find(args.specs)
# 
#     @staticmethod
#     def _read_specs(spec_locations):
#         return SpecReader(fs_resource_reader).read(spec_locations)
# 
#     @staticmethod
#     def _load_specs(runner_context: RunnerContext, spec_locations_and_contents):
#         return SpecLoader(runner_context, ast_chain).load(spec_locations_and_contents)
# 
#     @staticmethod
#     def _execute_specs(execution_framework, specs):
#         return SpecExecutor(execution_framework).execute(specs)


from io import StringIO
from nimoy.runner.metadata import RunnerContext
from nimoy.runner.spec_finder import Location
from nimoy.runner.unittest_execution_framework import UnitTestExecutionFramework
from nimoy.spec_runner import SpecRunner



def run_spec_contents(spec_contents):
    str_io = StringIO()
    execution_framework = UnitTestExecutionFramework(stream=str_io)

# Path: nimoy/runner/metadata.py
# class RunnerContext:
# 
#     def __init__(self, use_power_assertions: bool = False):
#         self.use_power_assertions = use_power_assertions
# 
# Path: nimoy/runner/spec_finder.py
# class Location:
#     def __init__(self, suggested_location):
# 
#         # Format may be:
#         # - some_spec.py
#         # - some_spec.py::SpecName
#         # - some_spec.py::feature_name
#         # - some_spec.py::SpecName::feature_name
#         split_suggested_location = suggested_location.split("::")
# 
#         # some_spec.py
#         if len(split_suggested_location) == 1:
#             self.spec_path = split_suggested_location[0]
# 
#         # some_spec.py::SpecName or some_spec.py::feature_name
#         if len(split_suggested_location) == 2:
#             self.spec_path = split_suggested_location[0]
# 
#             # some_spec.py::SpecName
#             if split_suggested_location[1][0].isupper():
#                 self.spec_name = split_suggested_location[1]
# 
#             # some_spec.py::feature_name
#             else:
#                 self.feature_name = split_suggested_location[1]
# 
#         # some_spec.py::SpecName::feature_name
#         if len(split_suggested_location) == 3:
#             self.spec_path = split_suggested_location[0]
#             self.spec_name = split_suggested_location[1]
#             self.feature_name = split_suggested_location[2]
# 
# Path: nimoy/runner/unittest_execution_framework.py
# class UnitTestExecutionFramework:
#     def __init__(self, stream=None):
#         self.suite = unittest.TestSuite()
#         self.stream = stream
# 
#     def append_test(self, test):
#         self.suite.addTest(test)
# 
#     def run(self):
#         return unittest.TextTestRunner(stream=self.stream, verbosity=2).run(self.suite)
# 
# Path: nimoy/spec_runner.py
# class SpecRunner:
#     def run(self, execution_framework):
#         parser = argparse.ArgumentParser(prog='nimoy', description='Run a suite of Nimoy specs.')
#         parser.add_argument('--power-assertions', metavar='P', type=bool, nargs=1, default=False,
#                             help="Should Nimoy evaluate comparison expressions using power assertions (beta)")
#         parser.add_argument('specs', metavar='S', type=str, nargs='*',
#                             help="""A path to a spec file to execute or a directory to scan for spec files.
#                                     When naming a file it is possible to select which spec or feature to run. some_spec.py[::SpecName[::feature_name]]
#                                     """)
# 
#         args = parser.parse_args()
# 
#         spec_locations = SpecRunner._find_specs(args)
#         spec_locations_and_contents = SpecRunner._read_specs(spec_locations)
#         return SpecRunner._run_on_contents(RunnerContext(use_power_assertions=args.power_assertions),
#                                            execution_framework, spec_locations_and_contents)
# 
#     @staticmethod
#     def _run_on_contents(runner_context: RunnerContext, execution_framework, spec_locations_and_contents):
#         specs = SpecRunner._load_specs(runner_context, spec_locations_and_contents)
#         return SpecRunner._execute_specs(execution_framework, specs)
# 
#     @staticmethod
#     def _find_specs(args):
#         return SpecFinder(os.getcwd()).find(args.specs)
# 
#     @staticmethod
#     def _read_specs(spec_locations):
#         return SpecReader(fs_resource_reader).read(spec_locations)
# 
#     @staticmethod
#     def _load_specs(runner_context: RunnerContext, spec_locations_and_contents):
#         return SpecLoader(runner_context, ast_chain).load(spec_locations_and_contents)
# 
#     @staticmethod
#     def _execute_specs(execution_framework, specs):
#         return SpecExecutor(execution_framework).execute(specs)


# Path: specs/nimoy/runner_helper.py
from io import StringIO
from nimoy.runner.metadata import RunnerContext
from nimoy.runner.spec_finder import Location
from nimoy.runner.unittest_execution_framework import UnitTestExecutionFramework
from nimoy.spec_runner import SpecRunner




def run_spec_contents(spec_contents):
    str_io = StringIO()
    execution_framework = UnitTestExecutionFramework(stream=str_io)

    return SpecRunner._run_on_contents(RunnerContext(), execution_framework,