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


Python assertions.assert_raises函数代码示例

本文整理汇总了Python中tests.assertions.assert_raises函数的典型用法代码示例。如果您正苦于以下问题:Python assert_raises函数的具体用法?Python assert_raises怎么用?Python assert_raises使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: test_valid_cleanup_action_name_fail

 def test_valid_cleanup_action_name_fail(self):
     assert_raises(
         ConfigError,
         valid_cleanup_action_name,
         'other',
         NullConfigContext,
     )
开发者ID:pombredanne,项目名称:Tron,代码行数:7,代码来源:config_parse_test.py

示例2: test_set_action_runs_duplicate

 def test_set_action_runs_duplicate(self):
     run_collection = mock.create_autospec(actionrun.ActionRunCollection)
     assert_raises(
         ValueError,
         self.job_run._set_action_runs,
         run_collection,
     )
开发者ID:pombredanne,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py

示例3: test_disabled_with_exception

    def test_disabled_with_exception(self):
        def testfunc():
            with self.manager.disabled():
                raise ValueError()

        assert_raises(ValueError, testfunc)
        assert self.manager.enabled
开发者ID:Yelp,项目名称:Tron,代码行数:7,代码来源:statemanager_test.py

示例4: test_create_missing_master

 def test_create_missing_master(self):
     config_mapping = {'other': mock.Mock()}
     assert_raises(
         ConfigError,
         config_parse.ConfigContainer.create,
         config_mapping,
     )
开发者ID:pombredanne,项目名称:Tron,代码行数:7,代码来源:config_parse_test.py

示例5: test_validate_metadata_mismatch

 def test_validate_metadata_mismatch(self):
     metadata = {'version': (200, 1, 1)}
     assert_raises(
         VersionMismatchError,
         StateMetadata.validate_metadata,
         metadata,
     )
开发者ID:Yelp,项目名称:Tron,代码行数:7,代码来源:statemanager_test.py

示例6: test_working_dir_with_exception

    def test_working_dir_with_exception(self):
        def with_exc():
            with tool_utils.working_dir(self.temp_dir):
                assert_equal(os.getcwd(), self.temp_dir)
                raise Exception("oops")

        assert_raises(Exception, with_exc)
        assert_equal(os.getcwd(), self.cwd)
开发者ID:Codeacious,项目名称:Tron,代码行数:8,代码来源:tool_utils_test.py

示例7: test_valid_time_invalid

 def test_valid_time_invalid(self):
     assert_raises(
         ConfigError,
         config_utils.valid_time,
         "14:32:12:34",
         self.context,
     )
     assert_raises(ConfigError, config_utils.valid_time, None, self.context)
开发者ID:Yelp,项目名称:Tron,代码行数:8,代码来源:config_utils_test.py

示例8: test_valid_time_delta_invalid_unit

 def test_valid_time_delta_invalid_unit(self):
     for jitter in ['1 year', '3 mo', '3 months']:
         assert_raises(
             ConfigError,
             config_utils.valid_time_delta,
             jitter,
             self.context,
         )
开发者ID:Yelp,项目名称:Tron,代码行数:8,代码来源:config_utils_test.py

示例9: test_save_failed

 def test_save_failed(self):
     self.store.save.side_effect = PersistenceStoreError("blah")
     assert_raises(
         PersistenceStoreError,
         self.manager.save,
         None,
         None,
         None,
     )
开发者ID:Yelp,项目名称:Tron,代码行数:9,代码来源:statemanager_test.py

示例10: test_post_validation_failed

 def test_post_validation_failed(self):
     if 'SSH_AUTH_SOCK' in os.environ:
         del os.environ['SSH_AUTH_SOCK']
     assert_raises(
         ConfigError,
         config_parse.valid_ssh_options.validate,
         self.config,
         self.context,
     )
开发者ID:pombredanne,项目名称:Tron,代码行数:9,代码来源:config_parse_test.py

示例11: test_validate_unknown_nodes

 def test_validate_unknown_nodes(self):
     service = {
         'name': 'some_name',
         'node': 'unknown_node',
         'command': 'do things',
         'pid_file': '/tmp',
         'monitor_interval': 30
     }
     config = {'services': [service]}
     self.container.add('third', config)
     assert_raises(ConfigError, self.container.validate)
开发者ID:strategist922,项目名称:Tron,代码行数:11,代码来源:config_parse_test.py

示例12: test_invalid_mode

 def test_invalid_mode(self):
     config = {
         'container_path': '/nail/srv',
         'host_path': '/tmp',
         'mode': 'RA',
     }
     assert_raises(
         ConfigError,
         config_parse.valid_volume.validate,
         config,
         self.context,
     )
开发者ID:pombredanne,项目名称:Tron,代码行数:12,代码来源:config_parse_test.py

示例13: test_missing_container_path

 def test_missing_container_path(self):
     config = {
         'container_path_typo': '/nail/srv',
         'host_path': '/tmp',
         'mode': 'RO',
     }
     assert_raises(
         ConfigError,
         config_parse.valid_volume.validate,
         config,
         self.context,
     )
开发者ID:pombredanne,项目名称:Tron,代码行数:12,代码来源:config_parse_test.py

示例14: test_check_consistency_failed

    def test_check_consistency_failed(self):
        state = {runstate.JOB_STATE: {'name': mock.Mock()}}

        with mock.patch.object(
            self.store,
            'save',
            side_effect=PersistenceStoreError,
            autospec=None,
        ):
            assert_raises(
                PersistenceStoreError,
                self.manager._check_consistency,
                state
            )
开发者ID:Yelp,项目名称:Tron,代码行数:14,代码来源:statemanager_test.py

示例15: test_invalid_job_collation

    def test_invalid_job_collation(self):
        jobs = FrozenDict({'test_collision0': ConfigJob(name='test_collision0',
            node='node0',
            schedule=ConfigIntervalScheduler(timedelta=datetime.timedelta(0,
                                                                          20)),
            actions=FrozenDict({'action0_0': ConfigAction(name='action0_0',
                                                          command='test_command0.0',
                                                          requires=(),
                                                          node=None)}),
            queueing=True,
            run_limit=50,
            all_nodes=False,
            cleanup_action=ConfigCleanupAction(command='test_command0.1',
                                               requires=(),
                                               name='cleanup',
                                               node=None),
            enabled=True,
            allow_overlap=False)})

        services = FrozenDict({'test_collision0': ConfigService(name='test_collision0',
                        node='node0',
                        pid_file='/var/run/%(name)s-%(instance_number)s.pid',
                        command='service_command0',
                        monitor_interval=20,
                        restart_interval=None,
                        count=2)})
        fake_config = mock.Mock()
        setattr(fake_config, 'jobs', jobs)
        setattr(fake_config, 'services', services)
        expected_message = "Collision found for identifier 'MASTER.test_collision0'"
        exception = assert_raises(ConfigError, collate_jobs_and_services, {'MASTER': fake_config})
        assert_in(expected_message, str(exception))
开发者ID:strategist922,项目名称:Tron,代码行数:32,代码来源:config_parse_test.py


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