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


Python FileUploadParser.parse方法代码示例

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


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

示例1: test_parse_missing_filename

# 需要导入模块: from rest_framework.parsers import FileUploadParser [as 别名]
# 或者: from rest_framework.parsers.FileUploadParser import parse [as 别名]
 def test_parse_missing_filename(self):
     """
     Parse raw file upload when filename is missing.
     """
     parser = FileUploadParser()
     self.stream.seek(0)
     self.parser_context['request'].META['HTTP_CONTENT_DISPOSITION'] = ''
     with self.assertRaises(ParseError):
         parser.parse(self.stream, None, self.parser_context)
开发者ID:99rockets,项目名称:django-rest-framework,代码行数:11,代码来源:test_parsers.py

示例2: test_parse_missing_filename

# 需要导入模块: from rest_framework.parsers import FileUploadParser [as 别名]
# 或者: from rest_framework.parsers.FileUploadParser import parse [as 别名]
 def test_parse_missing_filename(self):
     """
     Parse raw file upload when filename is missing.
     """
     parser = FileUploadParser()
     self.stream.seek(0)
     self.parser_context['request'].META['HTTP_CONTENT_DISPOSITION'] = ''
     with pytest.raises(ParseError) as excinfo:
         parser.parse(self.stream, None, self.parser_context)
     assert str(excinfo.value) == 'Missing filename. Request should include a Content-Disposition header with a filename parameter.'
开发者ID:YanyanZeng,项目名称:django-rest-framework,代码行数:12,代码来源:test_parsers.py

示例3: test_parse_missing_filename_large_file

# 需要导入模块: from rest_framework.parsers import FileUploadParser [as 别名]
# 或者: from rest_framework.parsers.FileUploadParser import parse [as 别名]
 def test_parse_missing_filename_large_file(self):
     """
     Parse raw file upload when filename is missing with TemporaryFileUploadHandler.
     """
     parser = FileUploadParser()
     self.stream.seek(0)
     self.parser_context["request"].upload_handlers = (TemporaryFileUploadHandler(),)
     self.parser_context["request"].META["HTTP_CONTENT_DISPOSITION"] = ""
     with pytest.raises(ParseError) as excinfo:
         parser.parse(self.stream, None, self.parser_context)
     assert (
         str(excinfo.value)
         == "Missing filename. Request should include a Content-Disposition header with a filename parameter."
     )
开发者ID:bmcool,项目名称:django-rest-framework,代码行数:16,代码来源:test_parsers.py

示例4: test_parse_missing_filename_multiple_upload_handlers

# 需要导入模块: from rest_framework.parsers import FileUploadParser [as 别名]
# 或者: from rest_framework.parsers.FileUploadParser import parse [as 别名]
 def test_parse_missing_filename_multiple_upload_handlers(self):
     """
     Parse raw file upload with multiple handlers when filename is missing.
     Regression test for #2109.
     """
     parser = FileUploadParser()
     self.stream.seek(0)
     self.parser_context['request'].upload_handlers = (
         MemoryFileUploadHandler(),
         MemoryFileUploadHandler()
     )
     self.parser_context['request'].META['HTTP_CONTENT_DISPOSITION'] = ''
     with self.assertRaises(ParseError):
         parser.parse(self.stream, None, self.parser_context)
开发者ID:99rockets,项目名称:django-rest-framework,代码行数:16,代码来源:test_parsers.py

示例5: test_parse_missing_filename_multiple_upload_handlers

# 需要导入模块: from rest_framework.parsers import FileUploadParser [as 别名]
# 或者: from rest_framework.parsers.FileUploadParser import parse [as 别名]
 def test_parse_missing_filename_multiple_upload_handlers(self):
     """
     Parse raw file upload with multiple handlers when filename is missing.
     Regression test for #2109.
     """
     parser = FileUploadParser()
     self.stream.seek(0)
     self.parser_context['request'].upload_handlers = (
         MemoryFileUploadHandler(),
         MemoryFileUploadHandler()
     )
     self.parser_context['request'].META['HTTP_CONTENT_DISPOSITION'] = ''
     with pytest.raises(ParseError) as excinfo:
         parser.parse(self.stream, None, self.parser_context)
     assert str(excinfo.value) == 'Missing filename. Request should include a Content-Disposition header with a filename parameter.'
开发者ID:YanyanZeng,项目名称:django-rest-framework,代码行数:17,代码来源:test_parsers.py

示例6: test_parse

# 需要导入模块: from rest_framework.parsers import FileUploadParser [as 别名]
# 或者: from rest_framework.parsers.FileUploadParser import parse [as 别名]
 def test_parse(self):
     """ Make sure the `QueryDict` works OK """
     parser = FileUploadParser()
     self.stream.seek(0)
     data_and_files = parser.parse(self.stream, None, self.parser_context)
     file_obj = data_and_files.files['file']
     self.assertEqual(file_obj._size, 14)
开发者ID:etnperlong,项目名称:mese2014,代码行数:9,代码来源:test_parsers.py

示例7: test_parse

# 需要导入模块: from rest_framework.parsers import FileUploadParser [as 别名]
# 或者: from rest_framework.parsers.FileUploadParser import parse [as 别名]
 def test_parse(self):
     """
     Parse raw file upload.
     """
     parser = FileUploadParser()
     self.stream.seek(0)
     data_and_files = parser.parse(self.stream, None, self.parser_context)
     file_obj = data_and_files.files['file']
     assert file_obj._size == 14
开发者ID:YanyanZeng,项目名称:django-rest-framework,代码行数:11,代码来源:test_parsers.py


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