'Tests for label_for_field'

def test_label_for_field(self):

    self.assertEqual(label_for_field('title', Article), 'title')
    self.assertEqual(label_for_field('title2', Article), 'another    name')
    self.assertEqual(label_for_field('title2', Article, return_attr=True), ('another    name', None))
    self.assertEqual(label_for_field('__unicode__', Article), 'article')
    self.assertEqual(label_for_field('__str__', Article), 'article')
    self.assertRaises(AttributeError, (lambda : label_for_field('unknown', Article)))
    def test_callable(obj):
        return 'nothing'
    self.assertEqual(label_for_field(test_callable, Article), 'Test    callable')
    self.assertEqual(label_for_field(test_callable, Article, return_attr=True), ('Test    callable', test_callable))
    self.assertEqual(label_for_field('test_from_model', Article), 'Test    from    model')
    self.assertEqual(label_for_field('test_from_model', Article, return_attr=True), ('Test    from    model', Article.test_from_model))
    self.assertEqual(label_for_field('test_from_model_with_override', Article), 'not    What    you    Expect')
    self.assertEqual(label_for_field((lambda x: 'nothing'), Article), '--')
    class MockModelAdmin(object, ):
        def test_from_model(self, obj):
            return 'nothing'
        test_from_model.short_description = 'not    Really    the    Model'
    self.assertEqual(label_for_field('test_from_model', Article, model_admin=MockModelAdmin), 'not    Really    the    Model')
    self.assertEqual(label_for_field('test_from_model', Article, model_admin=MockModelAdmin, return_attr=True), ('not    Really    the    Model', MockModelAdmin.test_from_model))
