当前位置: 首页>>代码示例>>Python>>正文


Python TestCase.assertIsInstance方法代码示例

本文整理汇总了Python中unittest.TestCase.assertIsInstance方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase.assertIsInstance方法的具体用法?Python TestCase.assertIsInstance怎么用?Python TestCase.assertIsInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.TestCase的用法示例。


在下文中一共展示了TestCase.assertIsInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def _apply(self,
            put: unittest.TestCase,
            value,
            message_builder: asrt.MessageBuilder):
     put.assertIsInstance(value, tuple,
                          'Expects a tuple of StringFragments')
     asrt.matches_sequence(self._sequence_of_element_assertions).apply(put, value, message_builder)
开发者ID:emilkarlen,项目名称:exactly,代码行数:9,代码来源:concrete_value_assertions.py

示例2: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def _apply(self,
            put: unittest.TestCase,
            value: Any,
            message_builder: MessageBuilder):
     put.assertIsInstance(value,
                          self.expected,
                          message_builder.apply(self.message))
开发者ID:emilkarlen,项目名称:exactly,代码行数:9,代码来源:value_assertion.py

示例3: _check_type

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def _check_type(self,
                 put: unittest.TestCase,
                 actual,
                 message_builder: asrt.MessageBuilder
                 ):
     put.assertIsInstance(actual, self._expected_type,
                          message_builder.apply('Actual value is expected to be a ' + str(self._expected_type)))
开发者ID:emilkarlen,项目名称:exactly,代码行数:9,代码来源:dir_dependent_value.py

示例4: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def _apply(self,
            put: unittest.TestCase,
            value: spe.ResultAndStderr,
            message_builder: asrt.MessageBuilder):
     put.assertIsInstance(value, spe.ResultAndStderr)
     put.assertTrue(value.result.is_success,
                    message_builder.apply('Result is expected to indicate success'))
开发者ID:emilkarlen,项目名称:exactly,代码行数:9,代码来源:sub_process_result_check.py

示例5: _check_sub_class_properties

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
    def _check_sub_class_properties(self,
                                    put: unittest.TestCase,
                                    actual: DirDependentValue,
                                    tcds: HomeAndSds,
                                    message_builder: asrt.MessageBuilder):
        put.assertIsInstance(actual,
                             SingleDirDependentValue,
                             message_builder.apply('class'))
        assert isinstance(actual, SingleDirDependentValue)  # Type info for IDE

        put.assertEqual(self._resolving_dependency,
                        actual.resolving_dependency(),
                        message_builder.apply('resolving_dependency'))

        assertion_on_resolved_value = self.resolved_value(tcds)

        if not self._resolving_dependency or self._resolving_dependency == DirectoryStructurePartition.HOME:
            resolved_value_post_sds = actual.value_pre_sds(tcds.hds)
            assertion_on_resolved_value.apply(put,
                                              resolved_value_post_sds,
                                              message_builder.for_sub_component('value_pre_sds'))

        if not self._resolving_dependency or self._resolving_dependency == DirectoryStructurePartition.NON_HOME:
            resolved_value_post_sds = actual.value_post_sds(tcds.sds)
            assertion_on_resolved_value.apply(put,
                                              resolved_value_post_sds,
                                              message_builder.for_sub_component('value_pre_sds'))
开发者ID:emilkarlen,项目名称:exactly,代码行数:29,代码来源:dir_dep_value_assertions.py

示例6: check_both_single_and_multiple_line_source

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def check_both_single_and_multiple_line_source(
         self,
         put: unittest.TestCase,
         first_source_line_instruction_argument_source_template: str,
         act_phase_source_lines: list,
         expected_cmd_and_args: ValueAssertion,
         hds_contents: home_populators.HomePopulator = home_populators.empty()):
     instruction_argument_source = first_source_line_instruction_argument_source_template.format_map(
         self.format_map_for_template_string)
     for source, source_assertion in equivalent_source_variants_with_assertion(put, instruction_argument_source):
         # ARRANGE #
         os_process_executor = AtcOsProcessExecutorThatRecordsArguments()
         arrangement = Arrangement(source,
                                   act_phase_source_lines,
                                   atc_os_process_executor=os_process_executor,
                                   hds_contents=hds_contents)
         expectation = Expectation(source_after_parse=source_assertion)
         # ACT #
         check(put, arrangement, expectation)
         # ASSERT #
         put.assertFalse(os_process_executor.command.shell,
                         'Command should not indicate shell execution')
         actual_cmd_and_args = os_process_executor.command.args
         put.assertIsInstance(actual_cmd_and_args, list,
                              'Arguments of command to execute should be a list of arguments')
         put.assertTrue(len(actual_cmd_and_args) > 0,
                        'List of arguments is expected to contain at least the file|interpreter argument')
         expected_cmd_and_args.apply_with_message(put, actual_cmd_and_args, 'actual_cmd_and_args')
开发者ID:emilkarlen,项目名称:exactly,代码行数:30,代码来源:executable_file.py

示例7: check_exception

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
    def check_exception(self,
                        root_path: pathlib.Path,
                        actual: Exception,
                        put: unittest.TestCase):
        put.assertIsInstance(actual, SuiteParseError)

        expected_source = single_line_sequence(2, self.file_inclusion_line)

        expectation = matches_suite_parse_error(
            suite_file=asrt.equals(self.root_suite_based_at(root_path)),
            maybe_section_name=asrt.equals(phase_names.SETUP.plain),
            source=equals_line_sequence(expected_source),
            source_location=equals_source_location_path(
                SourceLocationPath(
                    SourceLocation(
                        expected_source,
                        self.root_suite_file,
                    ),
                    []
                )
            ),
            document_parser_exception=asrt.is_instance(sec_doc_exceptions.FileAccessError),
        )

        expectation.apply(put, actual)
开发者ID:emilkarlen,项目名称:exactly,代码行数:27,代码来源:suite_hierarchy_reading.py

示例8: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def _apply(self,
            put: unittest.TestCase,
            value,
            message_builder: asrt.MessageBuilder):
     put.assertIsInstance(value, type(self.expected), message_builder.apply('type of CrossReferenceId'))
     equality_checker = _CrossReferenceIdEqualsWhenClassIsEqual(self.expected, put, message_builder)
     equality_checker.visit(value)
开发者ID:emilkarlen,项目名称:exactly,代码行数:9,代码来源:cross_reference_id_va.py

示例9: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
    def _apply(self,
               put: unittest.TestCase,
               actual_phase_2_step_2_recorded_value,
               message_builder: asrt.MessageBuilder):
        put.assertIsInstance(actual_phase_2_step_2_recorded_value, dict,
                             'actual value should be a dictionary')

        for phase in sorted(self.expected_phase_2_step_2_recorded_value.keys(),
                            key=attrgetter('value')):
            put.assertIn(phase, self.expected_phase_2_step_2_recorded_value)
            expected_steps = self.expected_phase_2_step_2_recorded_value[phase]
            actual = actual_phase_2_step_2_recorded_value[phase]
            for expected_step in sorted(expected_steps.keys()):
                put.assertIn(expected_step, actual, 'Phase {}: Missing step: {}'.format(phase, expected_step))
                put.assertEqual(expected_steps[expected_step],
                                actual[expected_step],
                                '{}/{}'.format(phase, expected_step))
                put.assertEqual(len(expected_steps),
                                len(actual),
                                'Actual number of recorded steps for phase {} must not exceed expected'.format(phase))
                put.assertEqual(len(self.expected_phase_2_step_2_recorded_value),
                                len(actual_phase_2_step_2_recorded_value),
                                'Actual number of recorded phases must not exceed expected')
                # To be sure that above code does not miss any case
                put.assertEqual(self.expected_phase_2_step_2_recorded_value,
                                actual_phase_2_step_2_recorded_value,
                                'Recordings per phase and step')
开发者ID:emilkarlen,项目名称:exactly,代码行数:29,代码来源:phase_step_recordings.py

示例10: test_player_stackEvents

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def test_player_stackEvents(self):
     destination = self.game.tilemap.layers['pnjs'].find('monstre')[0]
     (dx, dy) = self.__calcule_delta(self.game.perso, destination)
     self.game.perso.move(dx, dy)
     self.game.player_stackEvents(self.game.perso,
                                  self.game.monster_layer,
                                  self.game.playerEvents)
     TestCase.assertGreater(self, len(self.game.playerEvents), 0)
     TestCase.assertIsInstance(self, self.game.playerEvents[0], Monster)
开发者ID:Projet5001,项目名称:projet5001-pyhton,代码行数:11,代码来源:test_game.py

示例11: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
    def _apply(self,
               put: unittest.TestCase,
               value: SandboxDirectoryStructure,
               message_builder: MessageBuilder):
        put.assertIsInstance(value, SandboxDirectoryStructure)

        fc = FileChecker(put, message_builder.apply(''))

        is_sandbox_directory_structure_after_execution(fc, str(value.root_dir))
开发者ID:emilkarlen,项目名称:exactly,代码行数:11,代码来源:sds_assertions.py

示例12: assert_is_list_of_act_phase_instructions

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
def assert_is_list_of_act_phase_instructions(put: unittest.TestCase, x):
    put.assertIsInstance(x, list,
                         'Invalid test input: Expecting list of ActPhaseInstruction:s. Found: ' + str(type(x)))
    i = 0
    for e in x:
        put.assertIsInstance(e, ActPhaseInstruction,
                             'Invalid test input: Element [%d]. Expecting an ActPhaseInstruction:s. Found: %s' %
                             (i, type(e)))
        i += 1
开发者ID:emilkarlen,项目名称:exactly,代码行数:11,代码来源:act_phase_execution.py

示例13: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def _apply(self,
            put: unittest.TestCase,
            value,
            message_builder: MessageBuilder):
     put.assertIsInstance(value, sh.SuccessOrHardError)
     if not value.is_success:
         put.fail('\n'.join([
             'Expected: success',
             'Actual  : hard_error: ' + str(value.failure_message)
         ]))
开发者ID:emilkarlen,项目名称:exactly,代码行数:12,代码来源:sh_assertions.py

示例14: _assertions

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
 def _assertions(self,
                 unittest_case: unittest.TestCase,
                 actual: FailureInfo):
     unittest_case.assertIsNotNone(actual,
                                   'Failure info should be present')
     unittest_case.assertIsInstance(actual, PhaseFailureInfo,
                                    'The failure is expected to be a {}'.format(str(PhaseFailureInfo)))
     assert isinstance(actual, PhaseFailureInfo)
     self.assertions_(unittest_case,
                      actual.phase_step.simple,
                      actual.failure_details)
开发者ID:emilkarlen,项目名称:exactly,代码行数:13,代码来源:failure_info_check.py

示例15: create_app

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertIsInstance [as 别名]
def create_app(test: unittest.TestCase) -> App:
    """
    Create an :py:class:`App <arobito.controlinterface.ControllerBackend.App>` instance

    :param test: The currently running unit test case
    :return: An instance of App
    """

    app = App()
    test.assertIsNotNone(app)
    test.assertIsInstance(app, App)
    return app
开发者ID:arobito,项目名称:arobito,代码行数:14,代码来源:ControllerBackend.py


注:本文中的unittest.TestCase.assertIsInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。