本文整理汇总了Python中ming.base.Object.make_safe方法的典型用法代码示例。如果您正苦于以下问题:Python Object.make_safe方法的具体用法?Python Object.make_safe怎么用?Python Object.make_safe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ming.base.Object
的用法示例。
在下文中一共展示了Object.make_safe方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_safe
# 需要导入模块: from ming.base import Object [as 别名]
# 或者: from ming.base.Object import make_safe [as 别名]
def test_safe(self):
now = datetime.now()
oid = ObjectId()
safe_obj = Object(
a=[1,2,3],
b=dict(a=12),
c=[ 'foo', 1, 1L, 1.0, now,
Decimal('0.3'), None, oid ])
safe_obj.make_safe()
self.assertEqual(safe_obj, dict(
a=[1,2,3], b=dict(a=12),
c=[ 'foo', 1, 1L, 1.0, now,
0.3, None, oid ]))
unsafe_obj = Object(
my_tuple=(1,2,3))
self.assertRaises(AssertionError, unsafe_obj.make_safe)
示例2: test_safe
# 需要导入模块: from ming.base import Object [as 别名]
# 或者: from ming.base.Object import make_safe [as 别名]
def test_safe(self):
now = datetime.now()
oid = ObjectId()
c = [ 'foo', 1, 1.0, now,
Decimal('0.3'), None, oid ]
if six.PY2:
c = [ 'foo', 1, long(1), 1.0, now,
Decimal('0.3'), None, oid ]
safe_obj = Object(
a=[1,2,3],
b=dict(a=12),
c=c)
safe_obj.make_safe()
expected = Object(
a=[1,2,3], b=dict(a=12),
c=c)
self.assertTrue(expected, safe_obj)
unsafe_obj = Object(
my_tuple=(1,2,3))
self.assertRaises(AssertionError, unsafe_obj.make_safe)