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


Python Serializer.from_plist方法代码示例

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


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

示例1: test_from_plist

# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import from_plist [as 别名]
    def test_from_plist(self):
        serializer = Serializer()

        sample_1 = serializer.from_plist('bplist00bybiplist1.0\x00\xd3\x01\x02\x03\x04\x05\x06SageTname[date_joined\x10\x1bf\x00D\x00a\x00n\x00i\x00e\x00lZ2010-03-27\x15\x1c %[email protected]\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00K')
        self.assertEqual(len(sample_1), 3)
        self.assertEqual(sample_1['name'], 'Daniel')
        self.assertEqual(sample_1['age'], 27)
        self.assertEqual(sample_1['date_joined'], u'2010-03-27')
开发者ID:hackoder,项目名称:django-tastypie,代码行数:10,代码来源:serializers.py

示例2: test_from_plist

# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import from_plist [as 别名]
    def test_from_plist(self):
        serializer = Serializer()

        sample_1 = serializer.from_plist(b'bplist00bybiplist1.0\x00\xd4\x01\x02\x03\x04\x05\x06\x07\x08WsnowmanSageTname[date_joineda&\x03\x10\x1bf\x00D\x00a\x00n\x00i\x00e\x00lZ2010-03-27\x15\x1e&*/;>@M\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\t\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00X')
        self.assertEqual(len(sample_1), 4)
        self.assertEqual(sample_1['name'], 'Daniel')
        self.assertEqual(sample_1['age'], 27)
        self.assertEqual(sample_1['date_joined'], '2010-03-27')
        self.assertEqual(sample_1['snowman'], u'☃')
开发者ID:7Geese,项目名称:django-tastypie,代码行数:11,代码来源:serializers.py

示例3: test_from_plist

# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import from_plist [as 别名]
    def test_from_plist(self):
        serializer = Serializer()

        sample_1 = serializer.from_plist(
            "bplist00bybiplist1.0\x00\xd3\x01\x02\x03\x04\x05\x06SageTname[date_joined\x10\x1bf\x00D\x00a\x00n\x00i\x00e\x00lZ2010-03-27\x15\x1c %[email protected]\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00K"
        )
        self.assertEqual(len(sample_1), 3)
        self.assertEqual(sample_1["name"], "Daniel")
        self.assertEqual(sample_1["age"], 27)
        self.assertEqual(sample_1["date_joined"], u"2010-03-27")
开发者ID:robhudson,项目名称:django-tastypie,代码行数:12,代码来源:serializers.py

示例4: ResourceTestCase

# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import from_plist [as 别名]

#.........这里部分代码省略.........
        """
        return self.assertEqual(resp.status_code, 501)

    def assertValidJSON(self, data):
        """
        Given the provided ``data`` as a string, ensures that it is valid JSON &
        can be loaded properly.
        """
        # Just try the load. If it throws an exception, the test case will fail.
        self.serializer.from_json(data)

    def assertValidXML(self, data):
        """
        Given the provided ``data`` as a string, ensures that it is valid XML &
        can be loaded properly.
        """
        # Just try the load. If it throws an exception, the test case will fail.
        self.serializer.from_xml(data)

    def assertValidYAML(self, data):
        """
        Given the provided ``data`` as a string, ensures that it is valid YAML &
        can be loaded properly.
        """
        # Just try the load. If it throws an exception, the test case will fail.
        self.serializer.from_yaml(data)

    def assertValidPlist(self, data):
        """
        Given the provided ``data`` as a string, ensures that it is valid
        binary plist & can be loaded properly.
        """
        # Just try the load. If it throws an exception, the test case will fail.
        self.serializer.from_plist(data)

    def assertValidJSONResponse(self, resp):
        """
        Given a ``HttpResponse`` coming back from using the ``client``, assert that
        you get back:

        * An HTTP 200
        * The correct content-type (``application/json``)
        * The content is valid JSON
        """
        self.assertHttpOK(resp)
        self.assertTrue(resp['Content-Type'].startswith('application/json'))
        self.assertValidJSON(resp.content)

    def assertValidXMLResponse(self, resp):
        """
        Given a ``HttpResponse`` coming back from using the ``client``, assert that
        you get back:

        * An HTTP 200
        * The correct content-type (``application/xml``)
        * The content is valid XML
        """
        self.assertHttpOK(resp)
        self.assertTrue(resp['Content-Type'].startswith('application/xml'))
        self.assertValidXML(resp.content)

    def assertValidYAMLResponse(self, resp):
        """
        Given a ``HttpResponse`` coming back from using the ``client``, assert that
        you get back:
开发者ID:grunskis,项目名称:django-tastypie,代码行数:69,代码来源:test.py


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