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


Python BytesIO.name方法代码示例

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


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

示例1: test_full_minidump

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
    def test_full_minidump(self):
        self.project.update_option('sentry:store_crash_reports', True)
        self.upload_symbols()

        with self.feature('organizations:event-attachments'):
            attachment = BytesIO(b'Hello World!')
            attachment.name = 'hello.txt'
            with open(os.path.join(os.path.dirname(__file__), 'fixtures', 'windows.dmp'), 'rb') as f:
                resp = self._postMinidumpWithHeader(f, {
                    'sentry[logger]': 'test-logger',
                    'some_file': attachment,
                })
                assert resp.status_code == 200

        event = Event.objects.get()

        insta_snapshot_stacktrace_data(self, event.data)

        attachments = sorted(
            EventAttachment.objects.filter(
                event_id=event.event_id),
            key=lambda x: x.name)
        hello, minidump = attachments

        assert hello.name == 'hello.txt'
        assert hello.file.type == 'event.attachment'
        assert hello.file.checksum == '2ef7bde608ce5404e97d5f042f95f89f1c232871'

        assert minidump.name == 'windows.dmp'
        assert minidump.file.type == 'event.minidump'
        assert minidump.file.checksum == '74bb01c850e8d65d3ffbc5bad5cabc4668fce247'
开发者ID:yaoqi,项目名称:sentry,代码行数:33,代码来源:test_minidump_full.py

示例2: test_absfile

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
 def test_absfile(self):
     fileobj = BytesIO(b"This is my absolute file.")
     fileobj.name = "hello2.txt"
     response = self.client.post('/api/v1/file/', {'myabsfile': fileobj})
     self.assertEqual(201, response.status_code)
     self.assertEqual('application/json', response['Content-Type'])
     content = json.loads(response.content.decode('utf-8'))
     self.assertIn('resource_uri', content)
     self.assertTrue(content['myabsfile'].startswith("http://"))
开发者ID:davinirjr,项目名称:django-whippedcream,代码行数:11,代码来源:test_basic.py

示例3: test_025

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
def test_025(res):
    content = six.b('éàù@')
    f = StringIO(six.b('éàù@'))
    f.name = 'test.txt'
    b = {'a': 'aa', 'b': six.b('éàù@'), 'f': f}
    h = {'content-type': "multipart/form-data"}
    r = res.post('/multipart4', payload=b, headers=h)
    t.eq(r.status_int, 200)
    t.eq(r.body_string(), content)
开发者ID:pashinin,项目名称:restkit,代码行数:11,代码来源:005-tst-resource.py

示例4: test_write_extracted_values_tee_stdout

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
def test_write_extracted_values_tee_stdout(tmpdir):
    readable = BytesIO(wexin)
    readable.name = tmpdir.join('0' + EXT_WEXIN).strpath
    def extract(src):
        yield 1
    writer = command.WriteExtractedValues(TeeStdOut, extract)
    ret = writer(readable)
    assert ret is None
    with tmpdir.join('0' + EXT_WEXOUT).open() as fp:
        assert fp.read() == '1\n'
开发者ID:eBay,项目名称:wextracto,代码行数:12,代码来源:test_command.py

示例5: get_temporary_file

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
def get_temporary_file(prefix):
    """Get a temporary file.

    :return:
    """
    image = Image.new('RGBA', size=(100, 100), color=(256, 0, 0))
    tmp_file = BytesIO()
    _tmp_file = tempfile.NamedTemporaryFile(prefix=prefix, suffix='.png')
    image.save(tmp_file, "PNG")
    tmp_file.seek(0)
    tmp_file.name = _tmp_file.name
    return tmp_file
开发者ID:barseghyanartur,项目名称:django-qartez,代码行数:14,代码来源:files.py

示例6: test_007

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
def test_007():
    from six import BytesIO as StringIO
    u = "http://%s:%s/multipart4" % (HOST, PORT)
    content = six.b('éàù@')
    f = StringIO(six.b('éàù@'))
    f.name = 'test.txt'
    b = {'a': 'aa', 'b': six.b('éàù@'), 'f': f}
    h = {'content-type': "multipart/form-data"}
    body, headers = multipart_form_encode(b, h, uuid.uuid4().hex)
    r = request(u, method='POST', body=body, headers=headers)
    t.eq(r.status_int, 200)
    t.eq(r.body_string(), content)
开发者ID:pashinin,项目名称:restkit,代码行数:14,代码来源:008-tst-request.py

示例7: test_disabled_attachments

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
    def test_disabled_attachments(self):
        self.upload_symbols()

        attachment = BytesIO(b'Hello World!')
        attachment.name = 'hello.txt'
        with open(os.path.join(os.path.dirname(__file__), 'fixtures', 'windows.dmp'), 'rb') as f:
            resp = self._postMinidumpWithHeader(f, {
                'sentry[logger]': 'test-logger',
                'some_file': attachment,
            })
            assert resp.status_code == 200

        event = Event.objects.get()
        attachments = list(EventAttachment.objects.filter(event_id=event.event_id))
        assert attachments == []
开发者ID:yaoqi,项目名称:sentry,代码行数:17,代码来源:test_minidump_full.py

示例8: test_upload

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
    def test_upload(self):
        fileobj = BytesIO(b"This is my file.")
        fileobj.name = "hello.txt"
        response = self.client.post('/api/v1/file/', {'myfile': fileobj})
        self.assertEqual(201, response.status_code)
        self.assertEqual('application/json', response['Content-Type'])
        content = json.loads(response.content.decode('utf-8'))
        self.assertIn('resource_uri', content)

        # Now we should be able to get this file?
        response = self.client.get(content['resource_uri'])
        self.assertEqual(200, response.status_code)
        self.assertEqual('application/json', response['Content-Type'])
        content = json.loads(response.content.decode('utf-8'))
        self.assertEqual('hello.txt', content['myfile'])
开发者ID:davinirjr,项目名称:django-whippedcream,代码行数:17,代码来源:test_basic.py

示例9: test_attachments_only_minidumps

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
    def test_attachments_only_minidumps(self):
        self.project.update_option('sentry:store_crash_reports', False)
        self.upload_symbols()

        with self.feature('organizations:event-attachments'):
            attachment = BytesIO(b'Hello World!')
            attachment.name = 'hello.txt'
            with open(os.path.join(os.path.dirname(__file__), 'fixtures', 'windows.dmp'), 'rb') as f:
                resp = self._postMinidumpWithHeader(f, {
                    'sentry[logger]': 'test-logger',
                    'some_file': attachment,
                })
                assert resp.status_code == 200

        event = Event.objects.get()

        attachments = list(EventAttachment.objects.filter(event_id=event.event_id))
        assert len(attachments) == 1
        hello = attachments[0]

        assert hello.name == 'hello.txt'
        assert hello.file.type == 'event.attachment'
        assert hello.file.checksum == '2ef7bde608ce5404e97d5f042f95f89f1c232871'
开发者ID:yaoqi,项目名称:sentry,代码行数:25,代码来源:test_minidump_full.py

示例10: test_stringio_with_name

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
 def test_stringio_with_name(self):
     """If a file object (StringIO) has a name attribute, use that in output"""
     file_obj = StringIO(b("test data"))
     file_obj.name = "Test StringIO Object"
     put(file_obj, "/")
     assert re.search(file_obj.name, sys.stdout.getvalue())
开发者ID:dmuralik,项目名称:datascience,代码行数:8,代码来源:test_operations.py

示例11: create_testfile

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
 def create_testfile(self, s):
     """Takes a str object and returns a file-like object that can be put in a POST request"""
     testfile = BytesIO(s.encode('utf-8'))
     testfile.name = 'testfile'
     return testfile
开发者ID:0xD3ADB33F,项目名称:rapidsms,代码行数:7,代码来源:tests.py

示例12: test_empty_minidump

# 需要导入模块: from six import BytesIO [as 别名]
# 或者: from six.BytesIO import name [as 别名]
 def test_empty_minidump(self):
     f = BytesIO()
     f.name = 'empty.dmp'
     response = self._postMinidumpWithHeader(f)
     assert response.status_code == 400
     assert response.content == '{"error":"Empty minidump upload received"}'
开发者ID:yaoqi,项目名称:sentry,代码行数:8,代码来源:test_minidump_full.py


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