def test_get_annotation(self):
"""Tests that get_annotation works for badly decorated functions."""
def decorator(fn):
def wrapper():
fn()
return wrapper
mock_logic = mock.Mock()
mock_logic._schema_annotation = mock.sentinel.logic_annotation
wrapper = decorator(mock_logic)
self.assertEqual(ResourceSchemaAnnotation.get_annotation(mock_logic),
mock.sentinel.logic_annotation)
self.assertEqual(ResourceSchemaAnnotation.get_annotation(wrapper),
mock.sentinel.logic_annotation)
wrapper._schema_annotation = mock.sentinel.wrapper_annotation
self.assertEqual(ResourceSchemaAnnotation.get_annotation(wrapper),
mock.sentinel.wrapper_annotation)
delattr(wrapper, '_schema_annotation')
delattr(mock_logic, '_schema_annotation')
self.assertIsNone(ResourceSchemaAnnotation.get_annotation(wrapper))
评论列表
文章目录