def test_get_verbose_name(): from django.contrib.auth.models import Permission, User user = User() p = Permission() assert get_verbose_name(user, 'username') == 'username' assert get_verbose_name(User, 'username') == 'username' assert get_verbose_name(User.objects.all(), 'username') == 'username' assert get_verbose_name(User.objects, 'username') == 'username' assert get_verbose_name(User.objects, get_field_by_name(user, 'username')[0]) == 'username' assert get_verbose_name(p, 'content_type.model') == 'python model class name' with pytest.raises(ValueError): get_verbose_name(object, 'aaa') with pytest.raises(ValueError): get_verbose_name(p, None)
def test_get_verbose_name(): from django.contrib.auth.models import User, Permission user = User() p = Permission() assert six.text_type(get_verbose_name(user, 'username')) == 'username' assert six.text_type(get_verbose_name(User, 'username')) == 'username' assert six.text_type(get_verbose_name(User.objects.all(), 'username')) == 'username' assert six.text_type(get_verbose_name(User.objects, 'username')) == 'username' assert six.text_type(get_verbose_name(User.objects, get_field_by_name(user, 'username')[0])) == 'username' assert six.text_type(get_verbose_name(p, 'content_type.model')) == 'python model class name' with pytest.raises(ValueError): get_verbose_name(object, 'aaa')
def test_get_verbose_name(): from django.contrib.auth.models import User, Permission user = User() p = Permission() assert six.text_type(get_verbose_name(user, 'username')) == 'username' assert six.text_type(get_verbose_name(User, 'username')) == 'username' assert six.text_type(get_verbose_name(User.objects.all(), 'username')) == 'username' assert six.text_type(get_verbose_name(User.objects, 'username')) == 'username' assert six.text_type(get_verbose_name(User.objects, user._meta.get_field_by_name('username')[0])) == 'username' assert six.text_type(get_verbose_name(p, 'content_type.model')) == 'python model class name' with pytest.raises(ValueError): get_verbose_name(object, 'aaa')
def verbose_name(model_or_queryset, field): """ templatetag wrapper to `adminactions.utils.get_verbose_name`_ """ return get_verbose_name(model_or_queryset, field)