def test_partial(self):
"""
You can use Filter macros to create partials from other Filter
types.
"""
MyDatetime = filter_macro(f.Datetime, timezone=12)
self.assertEqual(
MyDatetime().apply('2015-10-13 15:22:18'),
# By default, MyDatetime assumes a timezone of UTC+12...
datetime(2015, 10, 13, 3, 22, 18, tzinfo=utc),
)
self.assertEqual(
# ... however, we can override it.
MyDatetime(timezone=6).apply('2015-10-13 15:22:18'),
datetime(2015, 10, 13, 9, 22, 18, tzinfo=utc),
)
评论列表
文章目录