本文整理汇总了Python中plone.event.interfaces.IEventAccessor.something方法的典型用法代码示例。如果您正苦于以下问题:Python IEventAccessor.something方法的具体用法?Python IEventAccessor.something怎么用?Python IEventAccessor.something使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plone.event.interfaces.IEventAccessor
的用法示例。
在下文中一共展示了IEventAccessor.something方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_event_accessor
# 需要导入模块: from plone.event.interfaces import IEventAccessor [as 别名]
# 或者: from plone.event.interfaces.IEventAccessor import something [as 别名]
def test_event_accessor(self):
obj = MockObject()
tz = pytz.timezone('Europe/Vienna')
obj.start = datetime(2012, 12, 12, 10, 0, tzinfo=tz)
obj.end = datetime(2012, 12, 12, 12, 0, tzinfo=tz)
zope.interface.alsoProvides(obj, IEvent)
# Create accessor
acc = IEventAccessor(obj)
# Accessor getters
self.assertEqual(acc.start, obj.start)
self.assertEqual(acc.end, obj.end)
self.assertEqual(acc.duration, obj.end - obj.start)
# Accessor setters
start = datetime(2013, 4, 5, 16, 31, tzinfo=tz)
end = datetime(2013, 4, 5, 16, 35, tzinfo=tz)
acc.start = start
acc.end = end
self.assertTrue(acc.start == obj.start == start)
self.assertTrue(acc.end == obj.end == end)
# Accessor deletor
acc.something = True
self.assertTrue(acc.something == obj.something is True)
del acc.something
self.assertTrue(hasattr(acc, 'something') is False)
self.assertTrue(hasattr(obj, 'something') is False)
del acc.start
self.assertTrue(hasattr(acc, 'start') is False)
self.assertTrue(hasattr(obj, 'start') is False)