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


Python six.b函数代码示例

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


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

示例1: test_request_DATA_with_text_content

 def test_request_DATA_with_text_content(self):
     """
     Ensure request.DATA returns content for POST request with
     non-form content.
     """
     content = six.b('qwerty')
     content_type = 'text/plain'
     request = Request(factory.post('/', content, content_type=content_type))
     request.parsers = (PlainTextParser(),)
     self.assertEqual(request.DATA, content)
开发者ID:MobileWebApps,项目名称:backend-python-rest-gae,代码行数:10,代码来源:test_request.py

示例2: test_delete_instance_view

 def test_delete_instance_view(self):
     """
     DELETE requests to RetrieveUpdateDestroyAPIView should delete an object.
     """
     request = factory.delete('/1')
     response = self.view(request, pk=1).render()
     self.assertEquals(response.status_code, status.HTTP_204_NO_CONTENT)
     self.assertEquals(response.content, six.b(''))
     ids = [obj.id for obj in self.objects.all()]
     self.assertEquals(ids, [2, 3])
开发者ID:limnick,项目名称:django-rest-framework,代码行数:10,代码来源:generics.py

示例3: test_standard_behaviour_determines_non_form_content_PUT

 def test_standard_behaviour_determines_non_form_content_PUT(self):
     """
     Ensure request.DATA returns content for PUT request with
     non-form content.
     """
     content = six.b('qwerty')
     content_type = 'text/plain'
     request = Request(factory.put('/', content, content_type=content_type))
     request.parsers = (PlainTextParser(), )
     self.assertEqual(request.DATA, content)
开发者ID:MobileWebApps,项目名称:backend-python-rest-gae,代码行数:10,代码来源:test_request.py

示例4: test_create

 def test_create(self):
     now = datetime.datetime.now()
     file = BytesIO(six.b("stuff"))
     file.name = "stuff.txt"
     file.size = len(file.getvalue())
     serializer = UploadedFileSerializer(data={"created": now}, files={"file": file})
     uploaded_file = UploadedFile(file=file, created=now)
     self.assertTrue(serializer.is_valid())
     self.assertEqual(serializer.object.created, uploaded_file.created)
     self.assertEqual(serializer.object.file, uploaded_file.file)
     self.assertFalse(serializer.object is uploaded_file)
开发者ID:jmagnusson,项目名称:django-rest-framework,代码行数:11,代码来源:files.py

示例5: test_validation_with_no_data

    def test_validation_with_no_data(self):
        """
        Validation should still function when no data dictionary is provided.
        """
        now = datetime.datetime.now()
        file = BytesIO(six.b('stuff'))
        file.name = 'stuff.txt'
        file.size = len(file.getvalue())
        uploaded_file = UploadedFile(file=file, created=now)

        serializer = UploadedFileSerializer(files={'file': file})
        self.assertFalse(serializer.is_valid())
开发者ID:2ndmouse,项目名称:django-rest-framework,代码行数:12,代码来源:test_files.py

示例6: test_remove_with_empty_string

    def test_remove_with_empty_string(self):
        """
        Passing empty string as data should cause file to be removed

        Test for:
        https://github.com/tomchristie/django-rest-framework/issues/937
        """
        now = datetime.datetime.now()
        file = BytesIO(six.b('stuff'))
        file.name = 'stuff.txt'
        file.size = len(file.getvalue())

        uploaded_file = UploadedFile(file=file, created=now)

        serializer = UploadedFileSerializer(instance=uploaded_file, data={'created': now, 'file': ''})
        self.assertTrue(serializer.is_valid())
        self.assertEqual(serializer.object.created, uploaded_file.created)
        self.assertIsNone(serializer.object.file)
开发者ID:2ndmouse,项目名称:django-rest-framework,代码行数:18,代码来源:test_files.py

示例7: test_head_method_serializes_no_content

 def test_head_method_serializes_no_content(self):
     """No response must be included in HEAD requests."""
     resp = self.client.head('/')
     self.assertEqual(resp.status_code, DUMMYSTATUS)
     self.assertEqual(resp['Content-Type'], RendererA.media_type + '; charset=utf-8')
     self.assertEqual(resp.content, six.b(''))
开发者ID:0x64746b,项目名称:django-rest-framework,代码行数:6,代码来源:test_response.py

示例8: test_permission_denied_html_view

 def test_permission_denied_html_view(self):
     response = self.client.get('/permission_denied')
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
     self.assertEqual(response.content, six.b("403 Forbidden"))
     self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8')
开发者ID:MobileWebApps,项目名称:backend-python-rest-gae,代码行数:5,代码来源:test_htmlrenderer.py

示例9: test_not_found_html_view

 def test_not_found_html_view(self):
     response = self.client.get('/not_found')
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
     self.assertEqual(response.content, six.b("404 Not Found"))
     self.assertEqual(response['Content-Type'], 'text/html; charset=utf-8')
开发者ID:MobileWebApps,项目名称:backend-python-rest-gae,代码行数:5,代码来源:test_htmlrenderer.py

示例10: test_permission_denied_html_view_with_template

 def test_permission_denied_html_view_with_template(self):
     response = self.client.get('/permission_denied')
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
     self.assertEqual(response.content, six.b("403: Permission denied"))
     self.assertEqual(response['Content-Type'], 'text/html')
开发者ID:AkademieOlympia,项目名称:django-rest-framework,代码行数:5,代码来源:htmlrenderer.py

示例11: test_not_found_html_view_with_template

 def test_not_found_html_view_with_template(self):
     response = self.client.get('/not_found')
     self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
     self.assertEqual(response.content, six.b("404: Not found"))
     self.assertEqual(response['Content-Type'], 'text/html')
开发者ID:AkademieOlympia,项目名称:django-rest-framework,代码行数:5,代码来源:htmlrenderer.py

示例12: test_permission_denied_html_view

 def test_permission_denied_html_view(self):
     response = self.client.get('/permission_denied')
     self.assertEquals(response.status_code, 403)
     self.assertEquals(response.content, six.b("403 Forbidden"))
     self.assertEquals(response['Content-Type'], 'text/html')
开发者ID:AOAmara,项目名称:living-galapagos,代码行数:5,代码来源:htmlrenderer.py

示例13: test_not_found_html_view

 def test_not_found_html_view(self):
     response = self.client.get('/not_found')
     self.assertEquals(response.status_code, 404)
     self.assertEquals(response.content, six.b("404 Not Found"))
     self.assertEquals(response['Content-Type'], 'text/html')
开发者ID:AOAmara,项目名称:living-galapagos,代码行数:5,代码来源:htmlrenderer.py


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