# 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_finder.py
# class SpecFinder:
#     def __init__(self, working_directory) -> None:
#         super().__init__()
#         self.working_directory = working_directory
#         self.spec_locations = []
# 
#     def find(self, suggested_locations):
#         if not suggested_locations:
#             suggested_locations.append(self.working_directory)
#         self._find_specs_in_suggested_locations(suggested_locations)
# 
#         return self.spec_locations
# 
#     def _find_specs_in_suggested_locations(self, suggested_locations):
# 
#         for suggested_location in suggested_locations:
#             normalized_suggested_location = self._normalize_suggested_location(suggested_location)
# 
#             if 'spec.py' in normalized_suggested_location:
#                 self.spec_locations.append(Location(normalized_suggested_location))
#             else:
#                 self._find_specs_in_directory(normalized_suggested_location)
# 
#     def _normalize_suggested_location(self, suggested_location):
# 
#         if os.path.isabs(suggested_location):
#             return suggested_location
#         return os.path.join(self.working_directory, suggested_location)
# 
#     def _find_specs_in_directory(self, directory):
#         for root, _, file_names in os.walk(directory):
#             for filename in fnmatch.filter(file_names, '*spec.py'):
#                 self.spec_locations.append(Location(os.path.join(root, filename)))
# 
# 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)


import os
import tempfile
from nimoy.runner.spec_finder import Location
from nimoy.runner.spec_finder import SpecFinder
from nimoy.specification import Specification
        with when:
            spec_locations = SpecFinder('/some/working/dir').find([temp_spec.name])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ temp_spec.name

    def explicit_spec_directory(self):
        with when:
            spec_locations = SpecFinder('/some/working/dir').find([os.path.dirname(temp_spec.name)])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ temp_spec.name

    def relative_spec_path(self):
        with when:
            spec_locations = SpecFinder('/some/working/dir').find(['jim_spec.py'])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ '/some/working/dir/jim_spec.py'

    def full_path(self):
        with when:
            spec_locations = SpecFinder('/some/working/dir').find(['jim_spec.py::SpecName::feature_name'])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ '/some/working/dir/jim_spec.py'
            spec_locations[0].spec_name == 'SpecName'
            spec_locations[0].feature_name == 'feature_name'



# 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_finder.py
# class SpecFinder:
#     def __init__(self, working_directory) -> None:
#         super().__init__()
#         self.working_directory = working_directory
#         self.spec_locations = []
# 
#     def find(self, suggested_locations):
#         if not suggested_locations:
#             suggested_locations.append(self.working_directory)
#         self._find_specs_in_suggested_locations(suggested_locations)
# 
#         return self.spec_locations
# 
#     def _find_specs_in_suggested_locations(self, suggested_locations):
# 
#         for suggested_location in suggested_locations:
#             normalized_suggested_location = self._normalize_suggested_location(suggested_location)
# 
#             if 'spec.py' in normalized_suggested_location:
#                 self.spec_locations.append(Location(normalized_suggested_location))
#             else:
#                 self._find_specs_in_directory(normalized_suggested_location)
# 
#     def _normalize_suggested_location(self, suggested_location):
# 
#         if os.path.isabs(suggested_location):
#             return suggested_location
#         return os.path.join(self.working_directory, suggested_location)
# 
#     def _find_specs_in_directory(self, directory):
#         for root, _, file_names in os.walk(directory):
#             for filename in fnmatch.filter(file_names, '*spec.py'):
#                 self.spec_locations.append(Location(os.path.join(root, filename)))
# 
# 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_finder_spec.py
import os
import tempfile
from nimoy.runner.spec_finder import Location
from nimoy.runner.spec_finder import SpecFinder
from nimoy.specification import Specification

        with when:
            spec_locations = SpecFinder('/some/working/dir').find([temp_spec.name])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ temp_spec.name

    def explicit_spec_directory(self):
        with when:
            spec_locations = SpecFinder('/some/working/dir').find([os.path.dirname(temp_spec.name)])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ temp_spec.name

    def relative_spec_path(self):
        with when:
            spec_locations = SpecFinder('/some/working/dir').find(['jim_spec.py'])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ '/some/working/dir/jim_spec.py'

    def full_path(self):
        with when:
            spec_locations = SpecFinder('/some/working/dir').find(['jim_spec.py::SpecName::feature_name'])
        with then:
            len(spec_locations) == 1
            spec_locations[0].spec_path @ '/some/working/dir/jim_spec.py'
            spec_locations[0].spec_name == 'SpecName'
            spec_locations[0].feature_name == 'feature_name'



class SpecificationLocationSpec(Specification):