# 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/spec_reader.py
# class SpecReader:
#     def __init__(self, resource_reader) -> None:
#         super().__init__()
#         self.resource_reader = resource_reader
# 
#     def read(self, spec_locations):
#         def spec_contents():
#             for spec_file_location in spec_locations:
#                 text = self.resource_reader.read(spec_file_location.spec_path)
#                 yield (spec_file_location, text)
# 
#         return spec_contents()
# 
# Path: nimoy/specification.py
# class Specification(TestCase, metaclass=DataDrivenSpecification):
# 
#     def __init__(self, methodName='runTest'):
#         super().__init__(methodName)
#         self.thrown_exceptions = []
# 
#     def _feature_block_context(self, block_name):
#         return FeatureBlock(block_name, self.thrown_exceptions)
# 
#     def _compare(self, left, right, comparison_type_name):
#         Compare().compare(left, right, comparison_type_name)
# 
#     def _power_assert(self, expression: Dict):
#         PowerAssertions().assert_and_raise(expression)
# 
#     def _assert_mock(self, number_of_invocations, mock, method, *args):
#         MockAssertions().assert_mock(number_of_invocations, mock, method, *args)
# 
#     def _exception_thrown(self, expected_exception_type):
#         return ExceptionAssertions().assert_exception(self.thrown_exceptions, expected_exception_type)


from unittest import mock
from nimoy.runner.spec_finder import Location
from nimoy.runner.spec_reader import SpecReader
from nimoy.specification import Specification



class SpecificationReaderSpec(Specification):
    def read(self):
        with given:
            location = Location('/path/to/spec.py')
            reader_mock = mock.Mock()
            reader_mock.read.return_value = 'class Jimbob:\n    pass'

        with when:

# 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/spec_reader.py
# class SpecReader:
#     def __init__(self, resource_reader) -> None:
#         super().__init__()
#         self.resource_reader = resource_reader
# 
#     def read(self, spec_locations):
#         def spec_contents():
#             for spec_file_location in spec_locations:
#                 text = self.resource_reader.read(spec_file_location.spec_path)
#                 yield (spec_file_location, text)
# 
#         return spec_contents()
# 
# Path: nimoy/specification.py
# class Specification(TestCase, metaclass=DataDrivenSpecification):
# 
#     def __init__(self, methodName='runTest'):
#         super().__init__(methodName)
#         self.thrown_exceptions = []
# 
#     def _feature_block_context(self, block_name):
#         return FeatureBlock(block_name, self.thrown_exceptions)
# 
#     def _compare(self, left, right, comparison_type_name):
#         Compare().compare(left, right, comparison_type_name)
# 
#     def _power_assert(self, expression: Dict):
#         PowerAssertions().assert_and_raise(expression)
# 
#     def _assert_mock(self, number_of_invocations, mock, method, *args):
#         MockAssertions().assert_mock(number_of_invocations, mock, method, *args)
# 
#     def _exception_thrown(self, expected_exception_type):
#         return ExceptionAssertions().assert_exception(self.thrown_exceptions, expected_exception_type)


# Path: specs/nimoy/runner/specification_reader_spec.py
from unittest import mock
from nimoy.runner.spec_finder import Location
from nimoy.runner.spec_reader import SpecReader
from nimoy.specification import Specification




class SpecificationReaderSpec(Specification):
    def read(self):
        with given:
            location = Location('/path/to/spec.py')
            reader_mock = mock.Mock()
            reader_mock.read.return_value = 'class Jimbob:\n    pass'

        with when:

            spec_contents = SpecReader(reader_mock).read([location])