コード例 #1
0
 def _do_freeze(self, put: unittest.TestCase, source: StringSource):
     try:
         source.freeze()
     except HardErrorException as ex:
         put.fail(
             self._message_builder.for_sub_component('freeze').apply(
                 'freeze raised HardErrorException: ' + str(ex)))
コード例 #2
0
 def matches_w_trace(self, model: StringSource) -> MatchingResult:
     actual = model.contents().as_str
     if self.expected == actual:
         return self._new_tb().build_result(True)
     else:
         err_msg = 'not eq to "{}": "{}"'.format(self.expected, actual)
         return (self._new_tb().append_details(
             details.String(err_msg)).build_result(False))
コード例 #3
0
def transformed_string_source_from_writer(write: Callable[[StringSourceContents, TextIO], None],
                                          model: StringSource,
                                          get_transformer_structure: Callable[[], StructureRenderer],
                                          mem_buff_size: int,
                                          file_name: Optional[str] = None,
                                          ) -> StringSource:
    def new_structure_builder() -> StringSourceStructureBuilder:
        return model.new_structure_builder().with_transformed_by(get_transformer_structure())

    model_contents = model.contents()
    return cached_frozen.StringSourceWithCachedFrozen(
        new_structure_builder,
        contents_via_write_to.ContentsViaWriteTo(
            model_contents.tmp_file_space,
            _WriterOfTransformed(write, model_contents),
            file_name,
        ),
        mem_buff_size,
        file_name,
    )
コード例 #4
0
 def _mb_force_evaluation_of_model(self, model: StringSource):
     if self._force_evaluation_of_model:
         with model.contents().as_lines:
             pass
コード例 #5
0
def _get_contents_as_str(x: StringSource) -> str:
    return x.contents().as_str
コード例 #6
0
 def get_from(self, model: StringSource) -> str:
     return model.contents().as_str
コード例 #7
0
def get_string_source_contents(x: StringSource) -> StringSourceContents:
    return x.contents()
コード例 #8
0
ファイル: num_lines.py プロジェクト: emilkarlen/exactly
 def get_from(self, model: StringSource) -> int:
     ret_val = 0
     with model.contents().as_lines as lines:
         for _ in lines:
             ret_val += 1
     return ret_val
コード例 #9
0
 def get_string_matcher_model_as_single_string(
         model: StringSource) -> str:
     return model.contents().as_str
コード例 #10
0
ファイル: assertions.py プロジェクト: emilkarlen/exactly
def _freeze_string_source(x: StringSource):
    x.freeze()
コード例 #11
0
ファイル: line_matchers.py プロジェクト: emilkarlen/exactly
def _get_line_elements(
    tcds: TestCaseDs, environment: ApplicationEnvironment,
    string_matcher_model: StringSource
) -> ContextManager[Iterator[LineMatcherLine]]:
    with string_matcher_model.contents().as_lines as lines:
        yield model_iter_from_file_line_iter(lines)
コード例 #12
0
ファイル: assertions.py プロジェクト: emilkarlen/exactly
 def _apply(self,
            put: unittest.TestCase,
            value: StringSource,
            message_builder: MessageBuilder,
            ):
     source_checker = contents_assertions.StringSourceContentsThatThatChecksLines(put, value.contents())
     self._check_lines_by_iterating_over_them(source_checker)
コード例 #13
0
 def _first_line(file_to_check: StringSource) -> str:
     with file_to_check.contents().as_lines as lines:
         for line in lines:
             return line
     return ''
コード例 #14
0
def _model_freezer(model: StringSource) -> StringSource:
    model.freeze()
    return model
コード例 #15
0
def _invoke_every_contents_method(string_source: StringSource):
    contents = string_source.contents()
    for method_case in properties_access.ALL_CASES__WO_LINES_ITER_CHECK:
        method_case.value(contents)
コード例 #16
0
def get_structure(model: StringSource) -> NodeRenderer:
    return model.structure()
コード例 #17
0
def _invoke_freeze(string_source: StringSource, num_times: int):
    for _ in range(num_times):
        string_source.freeze()
コード例 #18
0
 def matches_w_trace(self, model: StringSource) -> MatchingResult:
     actual = model.contents().as_str
     trace_builder = self._trace_builder(actual)
     return trace_builder.build_result(self._expected == actual)