def test_differs__relativity(self): # ARRANGE # expected = PathDdvTestImpl(RelOptionType.REL_ACT, path_ddvs.constant_path_part('file-name')) actual = PathDdvTestImpl(RelOptionType.REL_HDS_CASE, path_ddvs.constant_path_part('file-name')) assertion = sut.matches_path_sdv(expected, asrt.ignore, empty_symbol_table()) # ACT & ASSERT # assert_that_assertion_fails(assertion, path_sdvs.constant(actual))
def test_differs__exists_pre_sds(self): # ARRANGE # expected = PathDdvTestImpl(_EXISTS_PRE_SDS_RELATIVITY, path_ddvs.constant_path_part('file-name')) actual = PathDdvTestImpl(_NOT_EXISTS_PRE_SDS_RELATIVITY, path_ddvs.constant_path_part('file-name')) assertion = sut.matches_path_sdv(expected, asrt.ignore, empty_symbol_table()) # ACT & ASSERT # assert_that_assertion_fails(assertion, path_sdvs.constant(actual))
def check_exe_file(put: unittest.TestCase, expectation: ExpectationOnExeFile, actual: PathSdv): path_sdv_assertion = matches_path_sdv( expectation.path_ddv, expected_symbol_references=equals_symbol_references__w_str_rendering( expectation.expected_symbol_references), symbol_table=expectation.symbol_for_value_checks) path_sdv_assertion.apply_with_message(put, actual, 'path sdv') path_symbols = equals_symbol_references__w_str_rendering( expectation.expected_symbol_references) path_symbols.apply_with_message(put, actual.references, 'path-sdv/references')
def expect( resolved_path: PathDdv, expected_symbol_references: Assertion, symbol_table: SymbolTable, token_stream: Assertion, ) -> Expectation2: return Expectation2( path_sdv=matches_path_sdv(resolved_path, expected_symbol_references, symbol_table), symbol_table_in_with_all_ref_restrictions_are_satisfied=symbol_table, token_stream=token_stream, )
def test_differs__symbol_references(self): # ARRANGE # path = PathDdvTestImpl(RelOptionType.REL_ACT, path_ddvs.constant_path_part('file-name')) actual = PathSdvTestImplWithConstantPathAndSymbolReferences( path, [SymbolReference('symbol_name', ReferenceRestrictionsOnDirectAndIndirect( ArbitraryValueWStrRenderingRestriction.of_any()))]) assertion = sut.matches_path_sdv(path, asrt.matches_sequence([]), empty_symbol_table()) # ACT & ASSERT # assert_that_assertion_fails(assertion, actual)
def test_no_relativity_option_should_use_default_option(self): for is_after_act_phase in [False, True]: with self.subTest(is_after_act_phase=is_after_act_phase): arguments = 'single-argument' parser = sut.EmbryoParser( is_after_act_phase=is_after_act_phase) # ACT # actual = parser.parse(ARBITRARY_FS_LOCATION_INFO, remaining_source(arguments)) # ASSERT # expected_path = path_ddvs.of_rel_option( RelOptionType.REL_CWD, path_ddvs.constant_path_part(arguments)) assertion = matches_path_sdv(expected_path, asrt.is_empty) assertion.apply_without_message(self, actual.destination)
def test_rel_tmp_with_argument(self): for is_after_act_phase in [False, True]: with self.subTest(is_after_act_phase=is_after_act_phase): arguments = format_rel_options('{rel_tmp} subdir') parser = sut.EmbryoParser( is_after_act_phase=is_after_act_phase) # ACT # actual = parser.parse(ARBITRARY_FS_LOCATION_INFO, remaining_source(arguments)) # ASSERT # expected_path = path_ddvs.of_rel_option( RelOptionType.REL_TMP, path_ddvs.constant_path_part('subdir')) assertion = matches_path_sdv(expected_path, asrt.is_empty) assertion.apply_without_message(self, actual.destination)
def test_success_when_correct_number_of_arguments__escaped(self): for is_after_act_phase in [False, True]: with self.subTest(is_after_act_phase=is_after_act_phase): arguments = '"expected argument"' parser = sut.EmbryoParser( is_after_act_phase=is_after_act_phase) # ACT # actual = parser.parse(ARBITRARY_FS_LOCATION_INFO, remaining_source(arguments)) # ASSERT # expected_path = path_ddvs.of_rel_option( RelOptionType.REL_CWD, path_ddvs.constant_path_part('expected argument')) assertion = matches_path_sdv(expected_path, asrt.is_empty) assertion.apply_without_message(self, actual.destination)
def test_difference_in_relativity_root(self): symbols = empty_symbol_table() for relativity in _RELATIVITY_VARIANTS: for path_suffix in _PATH_SUFFIX_VARIANTS: test_case_descr = 'relativity:{}, path-suffix: {}'.format(relativity, type(path_suffix)) path = PathDdvTestImpl(relativity, path_suffix) path_sdv = path_sdvs.constant(path) with self.subTest(msg=sut.equals_path_sdv.__name__ + ' :: ' + test_case_descr): assertion = sut.equals_path_sdv(path_sdv) assertion.apply_without_message(self, path_sdv) with self.subTest(msg=sut.matches_path_sdv.__name__ + ' :: ' + test_case_descr): assertion = sut.matches_path_sdv(path, equals_symbol_references__w_str_rendering( path_sdv.references), symbols) assertion.apply_without_message(self, path_sdv)
def runTest(self): symbols = empty_symbol_table() for relativity in _RELATIVITY_VARIANTS: for path_suffix in _PATH_SUFFIX_VARIANTS: for symbol_references in _SYMBOL_REFERENCES: path = PathDdvTestImpl(relativity, path_suffix) path_sdv = PathSdvTestImplWithConstantPathAndSymbolReferences(path, symbol_references) test_case_descr = 'relativity:{}, path-suffix: {}'.format(relativity, type(path_suffix)) with self.subTest(msg=sut.equals_path_sdv.__name__ + ' :: ' + test_case_descr): assertion = sut.equals_path_sdv(path_sdv) assertion.apply_without_message(self, path_sdv) with self.subTest(msg=sut.matches_path_sdv.__name__ + ' :: ' + test_case_descr): assertion = sut.matches_path_sdv(path, equals_symbol_references__w_str_rendering( path_sdv.references), symbols) assertion.apply_without_message(self, path_sdv)