Example #1
0
 def expect_failure_because_specified_file_under_sds_is_missing(
     self,
     symbol_usages: Assertion[
         Sequence[SymbolUsage]] = asrt.is_empty_sequence,
 ):
     return Expectation(main_result=asrt_sh.is_hard_error(),
                        symbol_usages=symbol_usages)
Example #2
0
 def hard_error_from_prepare(
     error_message: Assertion[TextRenderer] = asrt_text_doc.is_any_text(),
     symbol_usages: Assertion[
         Sequence[SymbolUsage]] = asrt.is_empty_sequence,
 ) -> 'Expectation':
     return Expectation(symbol_usages=symbol_usages,
                        prepare=asrt_sh.is_hard_error(error_message))
Example #3
0
 def test_fail_due_to_unexpected_result__from_main(self):
     with self.assertRaises(utils.TestError):
         self._check(
             PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION,
             single_line_source(),
             sut.arrangement(),
             sut.Expectation(main_result=sh_assertions.is_hard_error()),
         )
Example #4
0
 def expect_failing_validation_post_setup(self,
                                          error_message: Assertion[TextRenderer] = asrt_text_doc.is_any_text(),
                                          symbol_usages: Assertion[Sequence[SymbolUsage]] = asrt.is_empty_sequence,
                                          ):
     return ic.Expectation(
         main_result=asrt_sh.is_hard_error(error_message),
         symbol_usages=symbol_usages,
     )
 def test_fail_due_to_unexpected_result__from_main(self):
     with self.assertRaises(utils.TestError):
         self._check(
             PARSER_THAT_GIVES_SUCCESSFUL_INSTRUCTION,
             single_line_source(),
             sut.arrangement(),
             sut.Expectation(main_result=sh_assertions.is_hard_error()),
         )
Example #6
0
 def expect_failure_of_main(self,
                            assertion_on_error_message: Assertion[TextRenderer] = asrt_text_doc.is_any_text(),
                            symbol_usages: Assertion[Sequence[SymbolUsage]] = asrt.is_empty_sequence,
                            ):
     return ic.Expectation(
         main_result=asrt_sh.is_hard_error(assertion_on_error_message),
         symbol_usages=symbol_usages,
     )
 def test_fail_due_to_unexpected_result_from_main(self):
     with self.assertRaises(utils.TestError):
         self._check(
             utils.ParserThatGives(SUCCESSFUL_INSTRUCTION),
             utils.single_line_source(),
             sut.Arrangement(),
             sut.Expectation(main_result=sh_assertions.is_hard_error()),
         )
Example #8
0
 def test_fail_due_to_unexpected_result_from_main(self):
     with self.assertRaises(utils.TestError):
         self._check(
             utils.ParserThatGives(SUCCESSFUL_INSTRUCTION),
             utils.single_line_source(),
             sut.Arrangement(),
             sut.Expectation(main_result=sh_assertions.is_hard_error()),
         )
Example #9
0
 def expect_failing_validation_post_setup(
     self,
     assertion_on_error_message: Assertion[str] = asrt.anything_goes(),
     symbol_usages: Assertion[
         Sequence[SymbolUsage]] = asrt.is_empty_sequence,
 ):
     return Expectation(main_result=asrt_sh.is_hard_error(
         asrt_text_doc.is_string_for_test(assertion_on_error_message)),
                        symbol_usages=symbol_usages)
Example #10
0
 def runTest(self):
     file_name = 'existing-plain-file'
     self._check(
         syntax_for_assignment_of(file_name),
         Arrangement(
             root_dir_contents=DirContents([empty_file(file_name)])),
         Expectation(
             main_result=sh_assertions.is_hard_error())
     )
Example #11
0
 def test_destination_already_exists__without_explicit_destination(self):
     file_name = 'existing-file'
     file_to_install = DirContents([(File(file_name,
                                          'contents'))])
     self._run(file_name,
               Arrangement(
                   pre_contents_population_action=MAKE_SUB_DIR_OF_SDS_CURRENT_DIRECTORY,
                   hds_contents=case_home_dir_contents(file_to_install),
                   sds_contents_before_main=sds_populator.contents_in_resolved_dir(CWD_RESOLVER,
                                                                                   DirContents(
                                                                                       [empty_file(file_name)])),
               ),
               Expectation(
                   main_result=sh_assertions.is_hard_error())
               )
Example #12
0
 def test_destination_already_exists_in_destination_directory(self):
     src = 'src-file-name'
     dst = 'dst-dir-name'
     home_dir_contents = DirContents([(empty_file(src))])
     cwd_dir_contents = DirContents([Dir(dst,
                                         [empty_file(src)])])
     self._run('{} {}'.format(src, dst),
               Arrangement(
                   pre_contents_population_action=MAKE_SUB_DIR_OF_SDS_CURRENT_DIRECTORY,
                   hds_contents=case_home_dir_contents(home_dir_contents),
                   sds_contents_before_main=sds_populator.contents_in_resolved_dir(CWD_RESOLVER,
                                                                                   cwd_dir_contents),
               ),
               Expectation(
                   main_result=sh_assertions.is_hard_error())
               )
Example #13
0
 def test_fail(self):
     the_error_message = 'error message'
     cases = [
         ('is success',
          sh.new_sh_success(),
          asrt.anything_goes(),
          ),
         ('assertion on error message fails',
          sh.new_sh_hard_error(the_error_message),
          asrt.equals(the_error_message + ' - part of message not in actual'),
          ),
     ]
     for name, actual, assertion_on_error_message in cases:
         with self.subTest(name=name):
             # ARRANGE #
             assertion = sut.is_hard_error(assertion_on_error_message)
             # ACT #
             assert_that_assertion_fails(assertion, actual)
Example #14
0
 def test_pass(self):
     the_error_message = 'error message'
     cases = [
         ('no assertion on error message',
          sh.new_sh_hard_error(the_error_message),
          asrt.anything_goes(),
          ),
         ('assertion on error message',
          sh.new_sh_hard_error(the_error_message),
          asrt.equals(the_error_message),
          ),
     ]
     for name, actual, assertion_on_error_message in cases:
         with self.subTest(name=name):
             # ARRANGE #
             assertion = sut.is_hard_error(assertion_on_error_message)
             # ACT #
             assertion.apply_without_message(self, actual)
Example #15
0
 def expect_failure_of_main(self,
                            assertion_on_error_message: ValueAssertion = asrt.anything_goes()):
     return Expectation(main_result=sh_assertions.is_hard_error(assertion_on_error_message))
 def expect_failing_validation_post_setup(self,
                                          assertion_on_error_message: ValueAssertion = asrt.anything_goes()):
     return Expectation(main_result=sh_assertions.is_hard_error(assertion_on_error_message))
Example #17
0
 def expectation_for_non_zero_exitcode(self) -> Expectation:
     return Expectation(main_result=asrt_sh.is_hard_error())
Example #18
0
 def expect_target_is_not_a_directory(self):
     return Expectation(main_result=sh_assertions.is_hard_error())
Example #19
0
 def runTest(self):
     self._check(
         syntax_for_assignment_of('non-existing-path'),
         Arrangement(),
         Expectation(main_result=sh_assertions.is_hard_error()))
Example #20
0
 def expect_failure_to_create_dir(
         self, symbol_usages: Assertion = asrt.is_empty_sequence):
     return Expectation(main_result=asrt_sh.is_hard_error(),
                        symbol_usages=symbol_usages)
Example #21
0
 def expect_target_is_not_a_directory(self):
     return Expectation(main_result=asrt_sh.is_hard_error())
 def expect_hard_error_in_main(self) -> Expectation:
     return Expectation(main_result=sh_assertions.is_hard_error())
 def expectation_for_non_zero_exitcode(self) -> Expectation:
     return Expectation(main_result=sh_assertions.is_hard_error())
Example #24
0
 def expect_failure_to_create_dir(self,
                                  symbol_usages: ValueAssertion = asrt.is_empty_sequence):
     return Expectation(main_result=sh_assertions.is_hard_error(),
                        symbol_usages=symbol_usages)
Example #25
0
 def expect_failure_because_specified_file_under_sds_is_missing(
         self,
         symbol_usages: ValueAssertion = asrt.is_empty_sequence):
     return Expectation(main_result=sh_assertions.is_hard_error(),
                        symbol_usages=symbol_usages)
Example #26
0
 def expect_hard_error_in_main(self) -> Expectation:
     return Expectation(main_result=asrt_sh.is_hard_error())