def test_attr_formatter_chained(self): obj = mock.Mock() obj.letters = ['a', 'b', 'c'] letters_formatter = fmt.attr_proxy('letters', len) self.assertEqual(3, letters_formatter(obj))
def test_attr_formatter_plain(self): obj = mock.Mock() obj.foo = 'bar' foo_formatter = fmt.attr_proxy('foo') self.assertEqual('bar', foo_formatter(obj))