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


Python TestCase.assertTrue方法代码示例

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


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

示例1: what_is_session

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
    def what_is_session():
        with DocumentStore() as store:
            store.initialize()
            # region session_usage_1

            with store.open_session() as session:
                entity = Company(name= "Company")
                session.store(entity)
                session.save_changes()
                company_id = entity.Id

            with store.open_session() as session:
                entity = session.load(company_id, object_type= Company)
                print(entity.name)

            # endregion

            # region session_usage_2

            with store.open_session() as session:
                entity = session.load(company_id, object_type=Company)
                entity.name = "Another Company"
                session.save_changes()

            # endregion

            with store.open_session() as session:
                # region session_usage_3
                TestCase.assertTrue(session.load(company_id, object_type=Company)
                                    is session.load(company_id, object_type=Company))
开发者ID:efratshenhar,项目名称:docs,代码行数:32,代码来源:WhatIsSession.py

示例2: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [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

示例3: test_hideHud

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
 def test_hideHud(self):
     self.game.showHud('playerHud')
     TestCase.assertTrue(self,
                         self.game.tilemap.layers['playerHud'].visible)
     self.game.hideHud('playerHud')
     TestCase.assertFalse(self,
                          self.game.tilemap.layers['playerHud'].visible)
开发者ID:Projet5001,项目名称:projet5001-pyhton,代码行数:9,代码来源:test_game.py

示例4: check_both_single_and_multiple_line_source

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [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

示例5: test_main

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
	def test_main(self):
		url = "http://" + str(settings.getIpAddress()) + ":" + str(settings.globalVars.portNumber)
		url = url.strip()
		print('TEST SERVER @ ' + url)
		website = urllib2.urlopen(url)
		website_html = str(website.read())
		flag = website_html.__contains__("<pre>")
		TestCase.assertTrue(self,flag, "Invalid Server Response")
		pass
开发者ID:Jelloeater,项目名称:forgeLandWall,代码行数:11,代码来源:test_main.py

示例6: _apply

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

示例7: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
    def _apply(self,
               put: unittest.TestCase,
               value: T,
               message_builder: MessageBuilder):
        file_path = pathlib.Path(self.path_name)

        put.assertTrue(file_path.exists(),
                       message_builder.apply('Path should exist'))

        put.assertTrue(file_path.is_dir(),
                       message_builder.apply('Path should be a directory'))
开发者ID:emilkarlen,项目名称:exactly,代码行数:13,代码来源:keep_sandbox.py

示例8: _assert_table_contains

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
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')
开发者ID:emilkarlen,项目名称:exactly,代码行数:13,代码来源:symbol_table.py

示例9: assert_is_success_and_output_dir_contains_at_least_result_files

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
def assert_is_success_and_output_dir_contains_at_least_result_files(put: unittest.TestCase,
                                                                    expected: SubProcessResult,
                                                                    actual: sut.Result):
    put.assertTrue(actual.is_success,
                   'Result should indicate success')
    put.assertEqual(expected.exitcode,
                    actual.exit_code,
                    'Exit code')
    contents_assertion = assert_dir_contains_at_least_result_files(PROCESS_OUTPUT_WITH_NON_ZERO_EXIT_STATUS,
                                                                   actual.file_names)
    contents_assertion.apply(put, actual.output_dir_path)
开发者ID:emilkarlen,项目名称:exactly,代码行数:13,代码来源:sub_process_execution.py

示例10: first_line_should_be_exit_identifier

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
def first_line_should_be_exit_identifier(put: unittest.TestCase,
                                         output: str,
                                         expected_exit_value: ExitValue):
    lines = output.split()
    put.assertTrue(len(lines) > 0,
                   'There should be at least one line (found {})'.format(len(lines)))

    first_line = lines[0]

    put.assertEqual(expected_exit_value.exit_identifier,
                    first_line,
                    'first line')
开发者ID:emilkarlen,项目名称:exactly,代码行数:14,代码来源:keep_sandbox.py

示例11: _assert_source_is_not_at_eof_and_has_current_whole_line

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
def _assert_source_is_not_at_eof_and_has_current_whole_line(put: unittest.TestCase,
                                                            source: ParseSource,
                                                            expected_current_line: str):
    put.assertTrue(source.has_current_line,
                   'There should be remaining lines in the source')
    put.assertFalse(source.is_at_eof,
                    'There should be remaining source')
    put.assertEqual(expected_current_line,
                    source.current_line_text,
                    'Should should have given current line')
    put.assertEqual(expected_current_line,
                    source.remaining_part_of_current_line,
                    'Current line should be identical to remaining-part-of-current-line')
开发者ID:emilkarlen,项目名称:exactly,代码行数:15,代码来源:act_phase_source_parser.py

示例12: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
    def _apply(self,
               put: unittest.TestCase,
               actual: Pattern,
               message_builder: MessageBuilder):
        put.assertEqual(self.pattern_string,
                        actual.pattern,
                        'regex pattern string')
        for matching_string in self.matching_string_list:
            put.assertTrue(bool(actual.search(matching_string)),
                           'reg-ex should match "{}"'.format(matching_string))

        put.assertFalse(bool(actual.search(self.non_matching_string)),
                        'reg-ex should not match "{}"'.format(self.non_matching_string))
开发者ID:emilkarlen,项目名称:exactly,代码行数:15,代码来源:parse_regex.py

示例13: _apply

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
    def _apply(self,
               put: unittest.TestCase,
               value,
               message_builder: asrt.MessageBuilder):
        put.assertIsInstance(value, ConstantStringFragmentResolver)
        assert isinstance(value, ConstantStringFragmentResolver)  # Type info for IDE

        put.assertTrue(value.is_string_constant,
                       message_builder.apply('is_string_constant'))

        put.assertEqual(self.expected.string_constant,
                        value.string_constant,
                        message_builder.apply('string_constant'))
开发者ID:emilkarlen,项目名称:exactly,代码行数:15,代码来源:concrete_value_assertions.py

示例14: assert_equal_failure_details

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
def assert_equal_failure_details(unit_tc: unittest.TestCase,
                                 expected: FailureDetails,
                                 actual: FailureDetails):
    if expected.is_only_failure_message:
        unit_tc.assertTrue(actual.is_only_failure_message,
                           'An error message is expected')
        unit_tc.assertEqual(expected.failure_message,
                            actual.failure_message,
                            'The failure message should be the expected')
    else:
        unit_tc.assertFalse(actual.is_only_failure_message,
                            'An exception is expected')
        unit_tc.assertEqual(expected.exception,
                            actual.exception,
                            'The exception should be the expected')
开发者ID:emilkarlen,项目名称:exactly,代码行数:17,代码来源:single_instruction_executor.py

示例15: assert_is_file_with_contents

# 需要导入模块: from unittest import TestCase [as 别名]
# 或者: from unittest.TestCase import assertTrue [as 别名]
def assert_is_file_with_contents(test: unittest.TestCase,
                                 file_path: pathlib.Path,
                                 expected_content: str,
                                 msg=None):
    file_name = str(file_path)
    test.assertTrue(file_path.exists(),
                    'File should exist: ' + file_name)
    test.assertTrue(file_path.is_file(),
                    'Should be a regular file: ' + file_name)
    f = open(str(file_path))
    actual_contents = f.read()
    f.close()
    if msg is None:
        msg = 'Contents of:' + file_name
    test.assertEqual(expected_content,
                     actual_contents,
                     msg)
开发者ID:emilkarlen,项目名称:exactly,代码行数:19,代码来源:utils.py


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