Esempio n. 1
0
def assert_contents_and_that_last_child_is_returned(
        expected_xml: str,
        root: Element,
        ret_val_from_renderer: Element,
        put: unittest.TestCase):
    xml_string = as_unicode_str(root)
    put.assertEqual(expected_xml,
                    xml_string)
    put.assertIs(list(root)[-1],
                 ret_val_from_renderer)
Esempio n. 2
0
def _assert_table_contains(put: unittest.TestCase,
                           table: sut.SymbolTable,
                           expected_symbol: NameAndValue):
    put.assertTrue(table.contains(expected_symbol.name),
                   'table SHOULD contain the value')
    put.assertIn(expected_symbol.name,
                 table.names_set,
                 'names set should contain the value')
    put.assertIs(expected_symbol.value,
                 table.lookup(expected_symbol.name),
                 'lookup should fins the value')
Esempio n. 3
0
def _assert_table_contains(put: unittest.TestCase,
                           table: sut.SymbolTable,
                           expected_symbol: NameAndValue[ASymbolTableValue]):
    put.assertTrue(table.contains(expected_symbol.name),
                   'table SHOULD contain the value')
    put.assertIn(expected_symbol.name,
                 table.names_set,
                 'names set should contain the value')
    put.assertIs(expected_symbol.value,
                 table.lookup(expected_symbol.name),
                 'lookup should fins the value')
Esempio n. 4
0
def assert_contents_and_that_last_child_is_returned(
        expected: ET.Element,
        actual: Element,
        ret_val_from_renderer: Element,
        put: unittest.TestCase,
):
    assertion = asrt_xml.equals(expected)
    assertion.apply_with_message(
        put,
        actual,
        'XML',
    )
    put.assertIs(list(actual)[-1],
                 ret_val_from_renderer)
Esempio n. 5
0
 def check(self,
           put: unittest.TestCase,
           sr: reporting.SubSuiteReporter,
           msg_header=''):
     progress_reporter = sr.progress_reporter
     assert isinstance(progress_reporter, ExecutionTracingSubSuiteProgressReporter)
     put.assertIs(self.suite,
                  progress_reporter.sub_suite,
                  msg_header + 'Suite instance')
     put.assertEqual(len(self.case_and_result_status_list),
                     len(progress_reporter.case_begin_list),
                     msg_header + 'Number of invocations of case-begin')
     self._assert_correct_progress_reporter_invocations(progress_reporter, msg_header, put)
     self._assert_correct_sub_suite_reporter_invocations(sr, msg_header, put)
Esempio n. 6
0
 def check(self,
           put: unittest.TestCase,
           sr: reporting.SubSuiteReporter,
           msg_header=''):
     progress_reporter = sr.progress_reporter
     assert isinstance(progress_reporter,
                       ExecutionTracingSubSuiteProgressReporter)
     put.assertIs(self.suite, progress_reporter.sub_suite,
                  msg_header + 'Suite instance')
     put.assertEqual(len(self.case_and_result_status_list),
                     len(progress_reporter.case_begin_list),
                     msg_header + 'Number of invocations of case-begin')
     self._assert_correct_progress_reporter_invocations(
         progress_reporter, msg_header, put)
     self._assert_correct_sub_suite_reporter_invocations(
         sr, msg_header, put)
 def _apply(self,
            put: unittest.TestCase,
            value,
            message_builder: asrt.MessageBuilder):
     put.assertIsInstance(value, DataValueResolver)
     assert isinstance(value, DataValueResolver)
     put.assertEqual(TypeCategory.DATA,
                     value.type_category,
                     _ELEMENT_TYPE_ERROR_MESSAGE)
     put.assertIs(self.expected.data_value_type,
                  value.data_value_type,
                  'data_value_type')
     put.assertIs(self.expected.value_type,
                  value.value_type,
                  'value_type')
     _EqualsDataValueResolverVisitor(value, put, message_builder).visit(self.expected)
def _expect_string(put: unittest.TestCase,
                   source: ParseSource,
                   expectation: ExpectedString):
    # ACT #
    actual = sut.parse_from_parse_source(source)
    # ASSERT #
    put.assertIs(string_or_file.SourceType.STRING,
                 actual.source_type,
                 'source type')
    put.assertFalse(actual.is_file_ref,
                    'is_file_ref')
    assertion_on_here_doc = asrt_string.matches_primitive_string(asrt.equals(expectation.resolved_str),
                                                                 expectation.common.symbol_references,
                                                                 expectation.common.symbol_table)
    assertion_on_here_doc.apply_with_message(put, actual.string_resolver,
                                             'string_resolver')
    _expect_common(put, source, actual,
                   expectation.common)
def _expect_here_doc(put: unittest.TestCase,
                     source: ParseSource,
                     expectation: ExpectedHereDoc):
    # ACT #
    actual = sut.parse_from_parse_source(source)
    # ASSERT #
    put.assertIs(string_or_file.SourceType.HERE_DOC,
                 actual.source_type,
                 'source type')
    put.assertFalse(actual.is_file_ref,
                    'is_file_ref')
    assertion_on_here_doc = asrt_hd.matches_resolved_value(expectation.resolved_here_doc_lines,
                                                           expectation.common.symbol_references,
                                                           expectation.common.symbol_table)
    assertion_on_here_doc.apply_with_message(put, actual.string_resolver,
                                             'here_document')
    _expect_common(put, source, actual,
                   expectation.common)
def _expect_file_ref(put: unittest.TestCase,
                     source: ParseSource,
                     expectation: ExpectedFileRef,
                     rel_opt_arg_conf: RelOptionArgumentConfiguration = sut.CONFIGURATION,
                     ):
    # ACT #
    actual = sut.parse_from_parse_source(source, rel_opt_arg_conf)
    # ASSERT #
    put.assertIs(string_or_file.SourceType.PATH,
                 actual.source_type,
                 'source type')
    put.assertTrue(actual.is_file_ref,
                   'is_file_ref')
    symbol_references_assertion = equals_symbol_references(expectation.common.symbol_references)
    expected_file_ref_resolver = matches_file_ref_resolver(expectation.file_ref_value,
                                                           symbol_references_assertion,
                                                           symbol_table=expectation.common.symbol_table)
    expected_file_ref_resolver.apply_with_message(put, actual.file_reference_resolver,
                                                  'file_reference_resolver')
    _expect_common(put, source, actual,
                   expectation.common)
Esempio n. 11
0
 def _check_invokation_sequence(
         self,
         put: unittest.TestCase,
         sr: ExecutionTracingSubSuiteProgressReporter,
         msg_header=''):
     expected_num_cases = len(self.case_and_result_status_list)
     actual_num_events = len(sr.event_type_list)
     expected_num_events = 2 + 2 * expected_num_cases
     put.assertEqual(expected_num_events, actual_num_events,
                     msg_header + 'Total number of events')
     put.assertIs(
         EventType.SUITE_BEGIN, sr.event_type_list[0],
         msg_header + 'First event should be ' + str(EventType.SUITE_BEGIN))
     put.assertIs(
         EventType.SUITE_END, sr.event_type_list[-1],
         msg_header + 'Last event should be ' + str(EventType.SUITE_END))
     for case_idx in range(1, 1 + 2 * expected_num_cases, 2):
         put.assertIs(EventType.CASE_BEGIN, sr.event_type_list[case_idx],
                      msg_header + 'First event of case processing')
         put.assertIs(EventType.CASE_END, sr.event_type_list[case_idx + 1],
                      msg_header + 'Second event of case processing')
Esempio n. 12
0
 def _check_invokation_sequence(self,
                                put: unittest.TestCase,
                                sr: ExecutionTracingSubSuiteProgressReporter,
                                msg_header=''):
     expected_num_cases = len(self.case_and_result_status_list)
     actual_num_events = len(sr.event_type_list)
     expected_num_events = 2 + 2 * expected_num_cases
     put.assertEqual(expected_num_events,
                     actual_num_events,
                     msg_header + 'Total number of events')
     put.assertIs(EventType.SUITE_BEGIN,
                  sr.event_type_list[0],
                  msg_header + 'First event should be ' + str(EventType.SUITE_BEGIN))
     put.assertIs(EventType.SUITE_END,
                  sr.event_type_list[-1],
                  msg_header + 'Last event should be ' + str(EventType.SUITE_END))
     for case_idx in range(1, 1 + 2 * expected_num_cases, 2):
         put.assertIs(EventType.CASE_BEGIN,
                      sr.event_type_list[case_idx],
                      msg_header + 'First event of case processing')
         put.assertIs(EventType.CASE_END,
                      sr.event_type_list[case_idx + 1],
                      msg_header + 'Second event of case processing')
Esempio n. 13
0
class TestRadiology(TestCase):
    def __init__(self, table, col_list):
        super().__init__()
        self.table = table
        self.col_list = col_list

    def test_function(self):
        with mock.patch.object(__builtins__, 'input', lambda: 'some_input'):
            assert module == 'expected_output'

    if __name__ == "__main__":
        import helper_function.pccm_names as pccm_names
        table = 'mammography'
        col_list = pccm_names.names_radio_mass(table)
        # execute only if run as a script
        masscalc = MassCalcification(table,
                                     mammo_breast='right_breast',
                                     file_number='test',
                                     user_name='dk')
        masscalc.mammo_mass('1')
        masscalc.multiple_mass()

    TestCase.assertIs(self)
    pass
Esempio n. 14
0
def assert_is_null(put: unittest.TestCase, actual: sut.TokenStream):
    put.assertTrue(actual.is_null, 'is null')
    put.assertIs(LookAheadState.NULL, actual.look_ahead_state,
                 'look ahead state')
Esempio n. 15
0
 def _apply(self, put: unittest.TestCase, value: T,
            message_builder: MessageBuilder):
     put.assertIs(self.expected, value, message_builder.apply(self.message))
Esempio n. 16
0
 def _apply(self,
            put: unittest.TestCase,
            value: T,
            message_builder: MessageBuilder):
     put.assertIs(self.expected, value,
                  message_builder.apply(self.message))
Esempio n. 17
0
def assert_is_null(put: unittest.TestCase, actual: sut.TokenStream):
    put.assertTrue(actual.is_null,
                   'is null')
    put.assertIs(LookAheadState.NULL,
                 actual.look_ahead_state,
                 'look ahead state')