本文整理汇总了Python中tastypie.serializers.Serializer.to_simple方法的典型用法代码示例。如果您正苦于以下问题:Python Serializer.to_simple方法的具体用法?Python Serializer.to_simple怎么用?Python Serializer.to_simple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tastypie.serializers.Serializer
的用法示例。
在下文中一共展示了Serializer.to_simple方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test__to_simple__time
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__time(self):
serializer = Serializer()
self.assertEqual(serializer.to_simple(datetime.time(2, 31, 33), None), '02:31:33')
示例2: test__to_simple__datetime
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__datetime(self):
serializer = Serializer()
self.assertEqual(serializer.to_simple(datetime.datetime(2010, 12, 16, 2, 31, 33), None), '2010-12-16T02:31:33')
示例3: test__to_simple__date
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__date(self):
serializer = Serializer()
self.assertEqual(serializer.to_simple(datetime.date(2010, 12, 16), None), '2010-12-16')
示例4: test__to_simple__bundle
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__bundle(self):
serializer = Serializer()
val = Bundle(data={'foo': True})
self.assertEqual(serializer.to_simple(val, None), {'foo': True})
示例5: test__to_simple__string
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__string(self):
serializer = Serializer()
val = b"\xc3\xa1hhh! I'm letting all the \xc3\xa1's out of my body."
self.assertEqual(serializer.to_simple(val, None), u"áhhh! I'm letting all the á's out of my body.")
示例6: test__to_simple__tuple
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__tuple(self):
serializer = Serializer()
val = (True,)
self.assertEqual(serializer.to_simple(val, None), [True])
示例7: test__to_simple__list
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__list(self):
serializer = Serializer()
val = [True]
self.assertEqual(serializer.to_simple(val, None), [True])
示例8: test__to_simple__dict
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__dict(self):
serializer = Serializer()
val = {'foo': True}
self.assertEqual(serializer.to_simple(val, None), {'foo': True})
示例9: test__to_simple__bool
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__bool(self):
serializer = Serializer()
val = True
self.assertIs(serializer.to_simple(val, None), val)
示例10: test__to_simple__int
# 需要导入模块: from tastypie.serializers import Serializer [as 别名]
# 或者: from tastypie.serializers.Serializer import to_simple [as 别名]
def test__to_simple__int(self):
serializer = Serializer()
val = 1
self.assertIs(serializer.to_simple(val, None), val)