def error_info_matches( description: Assertion[ Optional[ErrorDescription]] = asrt.anything_goes(), source_location_path: Assertion[ Optional[SourceLocationPath]] = asrt.anything_goes(), section_name: Assertion[Optional[str]] = asrt.anything_goes() ) -> Assertion[ErrorInfo]: return asrt.is_instance_with__many(ErrorInfo, [ asrt.sub_component_many('description', ErrorInfo.description.fget, [ asrt.is_none_or_instance(ErrorDescription), description, ]), asrt.sub_component_many( 'source_location_path', ErrorInfo.source_location_path.fget, [ asrt.is_none_or_instance_with( SourceLocationPath, asrt_source_loc.matches_source_location_path(), ), source_location_path ]), asrt.sub_component_many('maybe_section_name', ErrorInfo.maybe_section_name.fget, [ asrt.is_none_or_instance(str), section_name, ]), ])
def _matches_reference_source_location_block( expected_name: str) -> Assertion[ReportBlock]: return asrt.is_instance_with__many( sut.ReferenceSourceLocationBlock, [ asrt.sub_component('name', _get_reference_block_symbol_name, asrt.equals(expected_name)) ], )
def _matches_definition_short_info_block( expected: SymbolDefinitionInfo) -> Assertion[ReportBlock]: return asrt.is_instance_with__many( sut.DefinitionShortInfoBlock, [ asrt.sub_component('name', _get_short_info_name, asrt.equals(expected.name())) ], )
def equals_test_case_reference( expected: TestCaseFileReference) -> Assertion[TestCaseFileReference]: return asrt.is_instance_with__many(TestCaseFileReference, [ asrt.sub_component('file_path', TestCaseFileReference.file_path.fget, asrt.equals(expected.file_path)), asrt.sub_component('path_relativity_root_dir', TestCaseFileReference.path_relativity_root_dir.fget, asrt.equals(expected.path_relativity_root_dir)), ])
def matches(value: Assertion[bool] = asrt.is_instance(bool), trace: Assertion[NodeRenderer[bool]] = asrt_trace_rendering. matches_node_renderer()) -> Assertion[MatchingResult]: return asrt.is_instance_with__many(MatchingResult, [ asrt.sub_component('value', MatchingResult.value.fget, asrt.is_instance_with(bool, value)), asrt.sub_component('trace', MatchingResult.trace.fget, asrt.is_instance_with(NodeRenderer, trace)), ])
def matches_element_properties( indentation: Assertion[Indentation] = matches_indentation(), text_style: Assertion[Optional[TextStyle]] = matches_text_style(), ) -> Assertion[ElementProperties]: return asrt.is_instance_with__many(ElementProperties, [ asrt.sub_component('indentation', ElementProperties.indentation.fget, indentation), asrt.sub_component('text_style', ElementProperties.text_style.fget, text_style), ])
def accessor_error_matches( error: Assertion[AccessErrorType] = asrt.anything_goes(), error_info: Assertion[ErrorInfo] = result_assertions. error_info_matches()) -> Assertion[AccessorError]: return asrt.is_instance_with__many(AccessorError, [ asrt.sub_component('error', AccessorError.error.fget, asrt.is_instance_with(AccessErrorType, error)), asrt.sub_component('error_info', AccessorError.error_info.fget, asrt.is_instance_with(ErrorInfo, error_info)), ])
def matches_logic_ddv(primitive_value: Callable[[TestCaseDs], Assertion], tcds: TestCaseDs = fake_tcds() ) -> Assertion[DirDependentValue]: return asrt.is_instance_with__many( FullDepsDdv, [ has_valid_description(), has_validator(), asrt_ddv.matches_dir_dependent_value__with_adv(primitive_value, tcds), ])
def equals( exit_code: int, stderr_contents: Optional[str]) -> Assertion[ExecutionResultAndStderr]: return asrt.is_instance_with__many(ExecutionResultAndStderr, [ asrt.sub_component('stderr', ExecutionResultAndStderr.stderr_contents.fget, asrt.equals(stderr_contents)), asrt.sub_component('exit_code', ExecutionResultAndStderr.exit_code.fget, asrt.equals(exit_code)), ])
def is_string_lines( strings: Assertion[Sequence[str]] = asrt.anything_goes(), ) -> Assertion[LineObject]: return asrt.is_instance_with__many( StringLinesObject, [ asrt.sub_component( 'strings', StringLinesObject.strings.fget, asrt.and_( [asrt.is_sequence_of(asrt.is_instance(str)), strings])), ], )
def matches_non_empty( lower_limit: Optional[int], upper_limit: Optional[int], ) -> Assertion[IntInterval]: return asrt.is_instance_with__many( IntInterval, [ asrt.sub_component('is_empty', _get_is_empty, asrt.equals(False)), asrt.sub_component('lower', _get_lower, asrt.equals(lower_limit)), asrt.sub_component('upper', _get_upper, asrt.equals(upper_limit)), ], )
def matches_indentation( level: Assertion[int] = asrt.anything_goes(), suffix: Assertion[str] = asrt.anything_goes(), ) -> Assertion[Indentation]: return asrt.is_instance_with__many(Indentation, [ asrt.sub_component('level', Indentation.level.fget, asrt.is_instance_with(int, level)), asrt.sub_component( 'suffix', Indentation.suffix.fget, asrt.is_instance_with(str, suffix), ), ])
def matches_matcher_ddv(primitive_value: Callable[[TestCaseDs], Assertion[MatcherWTrace]], tcds: TestCaseDs = fake_tcds() ) -> Assertion[DirDependentValue]: def get_primitive_value_assertion(tcds_: TestCaseDs) -> Assertion: return asrt.is_instance_with(MatcherWTrace, primitive_value(tcds_)) return asrt.is_instance_with__many( MatcherDdv, [ has_node_description(), has_validator(), asrt_ddv.matches_dir_dependent_value__with_adv(get_primitive_value_assertion, tcds), ])
def is_tree_detail( tree: Assertion[Node[Any]] = asrt.anything_goes(), ) -> Assertion[Detail]: return asrt.is_instance_with__many( TreeDetail, [ asrt.sub_component( 'tree', TreeDetail.tree.fget, asrt.is_not_none_and(asrt.and_([_MatchesNode(), tree])), ), ], )
def is_string(string: Assertion[str] = asrt.anything_goes(), string_is_line_ended: Assertion[bool] = asrt.anything_goes() ) -> Assertion[LineObject]: return asrt.is_instance_with__many( StringLineObject, [ asrt.sub_component('string', StringLineObject.string.fget, asrt.is_instance_with(str, string)), asrt.sub_component( 'string_is_line_ended', StringLineObject.string_is_line_ended.fget, asrt.is_instance_with(bool, string_is_line_ended)), ], )
def is_indented_detail( details: Assertion[Sequence[Detail]] = asrt.is_sequence_of( asrt.is_instance(Detail)), ) -> Assertion[Detail]: return asrt.is_instance_with__many( IndentedDetail, [ asrt.sub_component( 'values', IndentedDetail.details.fget, asrt.is_not_none_and(details), ), ], )
def is_string_detail( to_string_object: Assertion[ToStringObject] = asrt.anything_goes(), ) -> Assertion[Detail]: return asrt.is_instance_with__many( StringDetail, [ asrt.sub_component( 'string', StringDetail.string.fget, asrt.and_([ asrt_to_string.matches(asrt.anything_goes()), to_string_object, ])), ], )
def matches_instruction_with_parse_source_info( section_name: Assertion[str] = asrt.anything_goes(), current_source_file: Assertion[FileLocationInfo] = asrt.anything_goes(), ) -> Assertion[model.Instruction]: return asrt.is_instance_with__many( InstructionInSectionWithParseSourceInfo, [ asrt.sub_component( 'section_name', InstructionInSectionWithParseSourceInfo.section_name.fget, section_name), asrt.sub_component( 'current_source_file', lambda instr: instr.fs_location_info.current_source_file, current_source_file), ])
def matches_hard_error(failure_details: Assertion[ Optional[FailureDetails]] = asrt_failure_details.is_any_failure_message() ) -> Assertion[ExitCodeOrHardError]: return asrt.is_instance_with__many(ExitCodeOrHardError, [ asrt.sub_component( 'is_hard_error', ExitCodeOrHardError.is_hard_error.fget, asrt.is_true, ), asrt.sub_component( 'failure details', ExitCodeOrHardError.failure_details.fget, asrt.is_optional_instance_with(FailureDetails, failure_details), ), ])
def is_lower_and_upper(lower_limit: int, upper_limit: int) -> Assertion[Range]: return asrt.is_instance_with__many( LowerAndUpperLimitRange, [ asrt.sub_component('lower_limit', lambda x: x.lower_limit, asrt.equals(lower_limit) ), asrt.sub_component('upper_limit', lambda x: x.upper_limit, asrt.equals(upper_limit) ), ] )
def matches_line_element( line_object: Assertion[LineObject], properties: Assertion[ElementProperties] = matches_element_properties() ) -> Assertion[LineElement]: return asrt.is_instance_with__many(LineElement, [ asrt.sub_component( 'line object', LineElement.line_object.fget, asrt.is_instance_with(LineObject, line_object), ), asrt.sub_component( 'properties', LineElement.properties.fget, properties, ), ])
def is_with_interval( plain: Assertion[IntInterval], complement: Assertion[IntInterval] = asrt.anything_goes(), ) -> Assertion: return asrt.is_instance_with__many(WithIntInterval, [ asrt.sub_component( 'interval (positive)', _get_interval, plain, ), asrt.sub_component( 'interval (inversion)', _get_inversion, complement, ), ])
def matches( timeout_in_seconds: Assertion[Optional[int]] = asrt.anything_goes(), environ: Assertion[Optional[Dict[str, str]]] = asrt.anything_goes(), ) -> Assertion[ProcessExecutionSettings]: return asrt.is_instance_with__many(ProcessExecutionSettings, [ asrt.sub_component( 'timeout', ProcessExecutionSettings.timeout_in_seconds.fget, timeout_in_seconds, ), asrt.sub_component( 'environ', ProcessExecutionSettings.environ.fget, environ, ), ])
def matches(stdin: Assertion[Optional[ AdvWvAssertionModel[StringSource]]] = asrt.anything_goes(), environ: Assertion[Optional[Dict[ str, str]]] = asrt.is_none_or_instance( dict)) -> Assertion[SettingsBuilderAssertionModel]: return asrt.is_instance_with__many(SettingsBuilderAssertionModel, [ asrt.sub_component( 'environ', _get_environ, environ, ), _OptionalSettingsBuilderComponentAssertion( 'stdin', _get_stdin, stdin, ), ])
def matches_text_style( color: Assertion[Optional[ForegroundColor]] = asrt.is_none_or_instance( ForegroundColor), font_style: Assertion[Optional[FontStyle]] = asrt.is_none_or_instance( FontStyle), ) -> Assertion[TextStyle]: return asrt.is_instance_with__many(TextStyle, [ asrt.sub_component( 'color', TextStyle.color.fget, asrt.is_optional_instance_with(ForegroundColor, color), ), asrt.sub_component( 'font_style', TextStyle.font_style.fget, asrt.is_optional_instance_with(FontStyle, font_style), ), ])
def matches_file_location_info( abs_path_of_dir_containing_first_file_path: Assertion[pathlib.Path] = asrt.anything_goes(), file_path_rel_referrer: Assertion[Optional[pathlib.Path]] = asrt.anything_goes(), file_inclusion_chain: Assertion[Sequence[SourceLocation]] = asrt.anything_goes(), ) -> Assertion[FileLocationInfo]: return asrt.is_instance_with__many( FileLocationInfo, [ asrt.sub_component('abs_path_of_dir_containing_first_file_path', FileLocationInfo.abs_path_of_dir_containing_first_file_path.fget, abs_path_of_dir_containing_first_file_path), asrt.sub_component('file_path_rel_referrer', FileLocationInfo.file_path_rel_referrer.fget, file_path_rel_referrer), asrt.sub_component('file_inclusion_chain', FileLocationInfo.file_inclusion_chain.fget, file_inclusion_chain), ])
def matches_source_location_info( abs_path_of_dir_containing_first_file_path: Assertion[pathlib.Path] = asrt.anything_goes(), source_location_path: Assertion[SourceLocationPath] = asrt.anything_goes(), ) -> Assertion[SourceLocationInfo]: return asrt.is_instance_with__many( SourceLocationInfo, [ asrt.sub_component('abs_path_of_dir_containing_first_file_path', SourceLocationInfo.abs_path_of_dir_containing_first_file_path.fget, asrt.is_instance_with(pathlib.Path, abs_path_of_dir_containing_first_file_path) ), asrt.sub_component('source_location_path', SourceLocationInfo.source_location_path.fget, asrt.is_instance_with(SourceLocationPath, source_location_path), ), ])
def _matches_definition_source_block( expected: SymbolDefinitionInfo) -> Assertion[ReportBlock]: return asrt.is_instance_with__many( sut.DefinitionSourceBlock, [ asrt.sub_component( 'phase', _get_source_block_phase_enum, asrt.equals(expected.phase.the_enum), ), asrt.sub_component( 'source_location_info', _get_source_block_source_location_info, asrt_source_loc.equals_source_location_info( expected.definition.symbol_container.source_location), ), ], )
def is_pre_formatted_string_detail( to_string_object: Assertion[ToStringObject] = asrt.anything_goes(), string_is_line_ended: Assertion[bool] = asrt.anything_goes(), ) -> Assertion[Detail]: return asrt.is_instance_with__many( PreFormattedStringDetail, [ asrt.sub_component( 'to_string_object', PreFormattedStringDetail.object_with_to_string.fget, to_string_object, ), asrt.sub_component( 'string_is_line_ended', PreFormattedStringDetail.string_is_line_ended.fget, asrt.is_instance_with(bool, string_is_line_ended), ), ], )
def matches_major_block( minor_blocks: Assertion[Sequence[MinorBlock]] = asrt.anything_goes(), properties: Assertion[ElementProperties] = matches_element_properties( )) -> Assertion[MajorBlock]: return asrt.is_instance_with__many(MajorBlock, [ asrt.sub_component( 'minor blocks', MajorBlock.parts.fget, asrt.and_([ asrt.is_sequence_of(matches_minor_block(asrt.anything_goes())), minor_blocks, ]), ), asrt.sub_component( 'properties', MajorBlock.properties.fget, properties, ), ])