Skip to content

Commit

Permalink
Added tests with number fields for admin.utils.display_for_field().
Browse files Browse the repository at this point in the history
  • Loading branch information
xblitz authored and timgraham committed Apr 14, 2015
1 parent 072947a commit b333d10
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/admin_utils/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import unicode_literals

from datetime import datetime
from decimal import Decimal

from django import forms
from django.conf import settings
Expand All @@ -12,7 +13,7 @@
)
from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
from django.db import DEFAULT_DB_ALIAS, models
from django.test import TestCase
from django.test import TestCase, override_settings
from django.utils import six
from django.utils.formats import localize
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -172,6 +173,21 @@ def test_null_display_for_field(self):
display_value = display_for_field(None, models.FloatField())
self.assertEqual(display_value, EMPTY_CHANGELIST_VALUE)

def test_number_formats_display_for_field(self):
display_value = display_for_field(12345.6789, models.FloatField())
self.assertEqual(display_value, '12345.6789')

display_value = display_for_field(Decimal('12345.6789'), models.DecimalField())
self.assertEqual(display_value, '12345.6789')

@override_settings(USE_L10N=True, USE_THOUSAND_SEPARATOR=True)
def test_number_formats_with_thousand_seperator_display_for_field(self):
display_value = display_for_field(12345.6789, models.FloatField())
self.assertEqual(display_value, '12,345.6789')

display_value = display_for_field(Decimal('12345.6789'), models.DecimalField())
self.assertEqual(display_value, '12,345.6789')

def test_label_for_field(self):
"""
Tests for label_for_field
Expand Down

0 comments on commit b333d10

Please sign in to comment.