• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tests.temporary_file函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: test_put_pipeline_definition_with_json

 def test_put_pipeline_definition_with_json(self):
     with temporary_file('r+') as f:
         f.write(TEST_JSON)
         f.flush()
         cmdline = self.prefix
         cmdline += ' --pipeline-id name'
         cmdline += ' --pipeline-definition file://%s' % f.name
         result = {
             'pipelineId': 'name',
             'pipelineObjects': [
                 {"id": "S3ToS3Copy",
                  "name": "S3ToS3Copy",
                  "fields": [
                    {
                      "key": "input",
                      "refValue": "InputData"
                    },
                    {
                      "key": "output",
                      "refValue": "OutputData"
                    },
                    {
                      "key": "schedule",
                      "refValue": "CopyPeriod"
                    },
                    {
                      "key": "type",
                      "stringValue": "CopyActivity"
                    },
                  ]}]
         }
         self.assert_params_for_cmd(cmdline, result)
开发者ID:DocFrank,项目名称:aws-cli,代码行数:32,代码来源:test_arg_serialize.py


示例2: test_credential_process_returns_error

    def test_credential_process_returns_error(self):
        config = (
            '[profile processcreds]\n'
            'credential_process = %s --raise-error\n'
        )
        config = config % self.credential_process
        with temporary_file('w') as f:
            f.write(config)
            f.flush()
            self.environ['AWS_CONFIG_FILE'] = f.name

            session = Session(profile='processcreds')

            # This regex validates that there is no substring: b'
            # The reason why we want to validate that is that we want to
            # make sure that stderr is actually decoded so that in
            # exceptional cases the error is properly formatted.
            # As for how the regex works:
            # `(?!b').` is a negative lookahead, meaning that it will only
            # match if it is not followed by the pattern `b'`. Since it is
            # followed by a `.` it will match any character not followed by
            # that pattern. `((?!hede).)*` does that zero or more times. The
            # final pattern adds `^` and `$` to anchor the beginning and end
            # of the string so we can know the whole string is consumed.
            # Finally `(?s)` at the beginning makes dots match newlines so
            # we can handle a multi-line string.
            reg = r"(?s)^((?!b').)*$"
            with self.assertRaisesRegexp(CredentialRetrievalError, reg):
                session.get_credentials()
开发者ID:pplu,项目名称:botocore,代码行数:29,代码来源:test_credentials.py


示例3: test_can_specify_multiple_versions_from_config

    def test_can_specify_multiple_versions_from_config(self, client_creator):
        config_api_version = '2012-01-01'
        second_config_api_version = '2013-01-01'
        with temporary_file('w') as f:
            del self.environ['FOO_PROFILE']
            self.environ['FOO_CONFIG_FILE'] = f.name
            self.session = create_session(session_vars=self.env_vars)
            f.write('[default]\n')
            f.write('foo_api_versions =\n'
                    '    myservice = %s\n'
                    '    myservice2 = %s\n' % (
                        config_api_version, second_config_api_version)
            )
            f.flush()

            self.session.create_client('myservice', 'us-west-2')
            call_kwargs = client_creator.return_value.\
                create_client.call_args[1]
            self.assertEqual(call_kwargs['api_version'], config_api_version)

            self.session.create_client('myservice2', 'us-west-2')
            call_kwargs = client_creator.return_value.\
                create_client.call_args[1]
            self.assertEqual(
                call_kwargs['api_version'], second_config_api_version)
开发者ID:pplu,项目名称:botocore,代码行数:25,代码来源:test_session.py


示例4: test_uri_param

 def test_uri_param(self):
     p = self.get_param_object("ec2.DescribeInstances.Filters")
     with temporary_file("r+") as f:
         json_argument = json.dumps([{"Name": "instance-id", "Values": ["i-1234"]}])
         f.write(json_argument)
         f.flush()
         result = uri_param(p, "file://%s" % f.name)
     self.assertEqual(result, json_argument)
开发者ID:virajs,项目名称:aws-cli,代码行数:8,代码来源:test_argprocess.py


示例5: test_bucket_in_other_region_using_http

 def test_bucket_in_other_region_using_http(self):
     client = self.session.create_client("s3", "us-east-1", endpoint_url="http://s3.amazonaws.com/")
     with temporary_file("w") as f:
         f.write("foobarbaz" * 1024 * 1024)
         f.flush()
         with open(f.name, "rb") as body_file:
             response = client.put_object(Bucket=self.bucket_name, Key="foo.txt", Body=body_file)
         self.assert_status_code(response, 200)
开发者ID:neilramsay,项目名称:botocore,代码行数:8,代码来源:test_s3.py


示例6: test_with_csm_disabled_from_config

 def test_with_csm_disabled_from_config(self):
     with temporary_file('w') as f:
         del self.environ['FOO_PROFILE']
         self.environ['FOO_CONFIG_FILE'] = f.name
         f.write('[default]\n')
         f.write('csm_enabled=false\n')
         f.flush()
         self.assert_created_client_is_not_monitored(self.session)
开发者ID:boto,项目名称:botocore,代码行数:8,代码来源:test_session.py


示例7: test_bucket_in_other_region_using_http

 def test_bucket_in_other_region_using_http(self):
     http_endpoint = self.service.get_endpoint(endpoint_url="http://s3.amazonaws.com/")
     with temporary_file("w") as f:
         f.write("foobarbaz" * 1024 * 1024)
         f.flush()
         op = self.service.get_operation("PutObject")
         response = op.call(http_endpoint, bucket=self.bucket_name, key="foo.txt", body=open(f.name, "rb"))
         self.assertEqual(response[0].status_code, 200)
         self.keys.append("foo.txt")
开发者ID:reedobrien,项目名称:botocore,代码行数:9,代码来源:test_s3.py


示例8: test_config_loader_delegation

 def test_config_loader_delegation(self):
     with temporary_file('w') as f:
         f.write('[credfile-profile]\naws_access_key_id=a\n')
         f.write('aws_secret_access_key=b\n')
         f.flush()
         self.session.set_config_variable('credentials_file', f.name)
         self.session.profile = 'credfile-profile'
         # Now trying to retrieve the scoped config should not fail.
         self.assertEqual(self.session.get_scoped_config(), {})
开发者ID:Lumida,项目名称:botocore,代码行数:9,代码来源:test_session.py


示例9: test_bucket_in_other_region_using_http

 def test_bucket_in_other_region_using_http(self):
     client = self.session.create_client(
         's3', 'us-east-1', endpoint_url='http://s3.amazonaws.com/')
     with temporary_file('w') as f:
         f.write('foobarbaz' * 1024 * 1024)
         f.flush()
         with open(f.name, 'rb') as body_file:
             response = client.put_object(
                 Bucket=self.bucket_name,
                 Key='foo.txt', Body=body_file)
         self.assert_status_code(response, 200)
开发者ID:freimer,项目名称:botocore,代码行数:11,代码来源:test_s3.py


示例10: test_honors_aws_shared_credentials_file_env_var

    def test_honors_aws_shared_credentials_file_env_var(self):
        with temporary_file('w') as f:
            f.write('[default]\n'
                    'aws_access_key_id=custom1\n'
                    'aws_secret_access_key=custom2\n')
            f.flush()
            os.environ['AWS_SHARED_CREDENTIALS_FILE'] = f.name
            s = Session()
            credentials = s.get_credentials()

            self.assertEqual(credentials.access_key, 'custom1')
            self.assertEqual(credentials.secret_key, 'custom2')
开发者ID:adamchainz,项目名称:botocore,代码行数:12,代码来源:test_credentials.py


示例11: test_bucket_in_other_region

 def test_bucket_in_other_region(self):
     # This verifies expect 100-continue behavior.  We previously
     # had a bug where we did not support this behavior and trying to
     # create a bucket and immediately PutObject with a file like object
     # would actually cause errors.
     client = self.session.create_client("s3", "us-east-1")
     with temporary_file("w") as f:
         f.write("foobarbaz" * 1024 * 1024)
         f.flush()
         with open(f.name, "rb") as body_file:
             response = client.put_object(Bucket=self.bucket_name, Key="foo.txt", Body=body_file)
         self.assert_status_code(response, 200)
开发者ID:neilramsay,项目名称:botocore,代码行数:12,代码来源:test_s3.py


示例12: test_config_loader_delegation

 def test_config_loader_delegation(self):
     session = create_session(profile='credfile-profile')
     with temporary_file('w') as f:
         f.write('[credfile-profile]\naws_access_key_id=a\n')
         f.write('aws_secret_access_key=b\n')
         f.flush()
         session.set_config_variable('credentials_file', f.name)
         # Now trying to retrieve the scoped config should pull in
         # values from the shared credentials file.
         self.assertEqual(session.get_scoped_config(),
                          {'aws_access_key_id': 'a',
                           'aws_secret_access_key': 'b'})
开发者ID:boto,项目名称:botocore,代码行数:12,代码来源:test_session.py


示例13: test_full_config_merges_creds_file_data

    def test_full_config_merges_creds_file_data(self):
        with temporary_file('w') as f:
            self.session.set_config_variable('credentials_file', f.name)
            f.write('[newprofile]\n')
            f.write('aws_access_key_id=FROM_CREDS_FILE_1\n')
            f.write('aws_secret_access_key=FROM_CREDS_FILE_2\n')
            f.flush()

            full_config = self.session.full_config
            self.assertEqual(full_config['profiles']['newprofile'],
                             {'aws_access_key_id': 'FROM_CREDS_FILE_1',
                              'aws_secret_access_key': 'FROM_CREDS_FILE_2'})
开发者ID:brint,项目名称:botocore,代码行数:12,代码来源:test_session.py


示例14: test_can_override_session

    def test_can_override_session(self):
        with temporary_file('w') as f:
            # We're going to override _retry.json in 
            # botocore/data by setting our own data directory.
            override_name = self.create_file(
                f, contents='{"foo": "bar"}', name='_retry.json')
            new_data_path = os.path.dirname(override_name)
            loader = loaders.create_loader(search_path_string=new_data_path)

            new_content = loader.load_data('_retry')
            # This should contain the content we just created.
            self.assertEqual(new_content, {"foo": "bar"})
开发者ID:AdColony-Engineering,项目名称:botocore,代码行数:12,代码来源:test_loaders.py


示例15: test_bucket_in_other_region

 def test_bucket_in_other_region(self):
     # This verifies expect 100-continue behavior.  We previously
     # had a bug where we did not support this behavior and trying to
     # create a bucket and immediately PutObject with a file like object
     # would actually cause errors.
     with temporary_file("w") as f:
         f.write("foobarbaz" * 1024 * 1024)
         f.flush()
         op = self.service.get_operation("PutObject")
         response = op.call(self.endpoint, bucket=self.bucket_name, key="foo.txt", body=open(f.name, "rb"))
         self.assertEqual(response[0].status_code, 200)
         self.keys.append("foo.txt")
开发者ID:reedobrien,项目名称:botocore,代码行数:12,代码来源:test_s3.py


示例16: test_create_client_with_ca_bundle_from_config

    def test_create_client_with_ca_bundle_from_config(self, client_creator):
        with temporary_file('w') as f:
            del self.environ['FOO_PROFILE']
            self.environ['FOO_CONFIG_FILE'] = f.name
            f.write('[default]\n')
            f.write('foo_ca_bundle=config-certs.pem\n')
            f.flush()

            self.session.create_client('ec2', 'us-west-2')
            call_kwargs = client_creator.return_value.\
                create_client.call_args[1]
            self.assertEqual(call_kwargs['verify'], 'config-certs.pem')
开发者ID:boto,项目名称:botocore,代码行数:12,代码来源:test_session.py


示例17: test_path_not_in_available_profiles

    def test_path_not_in_available_profiles(self):
        with temporary_file('w') as f:
            self.session.set_config_variable('credentials_file', f.name)
            f.write('[newprofile]\n')
            f.write('aws_access_key_id=FROM_CREDS_FILE_1\n')
            f.write('aws_secret_access_key=FROM_CREDS_FILE_2\n')
            f.flush()

            profiles = self.session.available_profiles
            self.assertEqual(
                set(profiles),
                set(['foo', 'default', 'newprofile']))
开发者ID:vchan,项目名称:botocore,代码行数:12,代码来源:test_session.py


示例18: test_bucket_in_other_region_using_http

 def test_bucket_in_other_region_using_http(self):
     http_endpoint = self.service.get_endpoint(
         endpoint_url='http://s3.amazonaws.com/')
     with temporary_file('w') as f:
         f.write('foobarbaz' * 1024 * 1024)
         f.flush()
         op = self.service.get_operation('PutObject')
         response = op.call(http_endpoint,
                            bucket=self.bucket_name,
                            key='foo.txt',
                            body=open(f.name, 'rb'))
         self.assertEqual(response[0].status_code, 200)
         self.keys.append('foo.txt')
开发者ID:TelegramSam,项目名称:botocore,代码行数:13,代码来源:test_s3.py


示例19: test_create_client_uses_api_version_from_config

    def test_create_client_uses_api_version_from_config(self, client_creator):
        config_api_version = '2012-01-01'
        with temporary_file('w') as f:
            del self.environ['FOO_PROFILE']
            self.environ['FOO_CONFIG_FILE'] = f.name
            f.write('[default]\n')
            f.write('foo_api_versions =\n'
                    '    myservice = %s\n' % config_api_version)
            f.flush()

            self.session.create_client('myservice', 'us-west-2')
            call_kwargs = client_creator.return_value.\
                create_client.call_args[1]
            self.assertEqual(call_kwargs['api_version'], config_api_version)
开发者ID:boto,项目名称:botocore,代码行数:14,代码来源:test_session.py


示例20: test_credential_process

    def test_credential_process(self):
        config = (
            '[profile processcreds]\n'
            'credential_process = %s\n'
        )
        config = config % self.credential_process
        with temporary_file('w') as f:
            f.write(config)
            f.flush()
            self.environ['AWS_CONFIG_FILE'] = f.name

            credentials = Session(profile='processcreds').get_credentials()
            self.assertEqual(credentials.access_key, 'spam')
            self.assertEqual(credentials.secret_key, 'eggs')
开发者ID:pplu,项目名称:botocore,代码行数:14,代码来源:test_credentials.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tests.user_set函数代码示例发布时间:2022-05-27
下一篇:
Python tests.suite函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap