From 922fc89779cd5799195ad96e0a8fba67926e6e67 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Wed, 26 Apr 2017 09:28:48 -0400 Subject: [PATCH 01/13] Added to FIELDS. --- drf_braces/fields/_fields.py | 1 + 1 file changed, 1 insertion(+) diff --git a/drf_braces/fields/_fields.py b/drf_braces/fields/_fields.py index 28059de..559fe92 100644 --- a/drf_braces/fields/_fields.py +++ b/drf_braces/fields/_fields.py @@ -26,6 +26,7 @@ 'MultipleChoiceField', 'NullBooleanField', 'RegexField', + 'RoundedDecimalField', 'SlugField', 'TimeField', 'URLField', From d710d2264ee94f1e15563e35f4790c6a05357a4f Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Wed, 26 Apr 2017 11:08:08 -0400 Subject: [PATCH 02/13] Rewriting to not modify floats, just like DecimalField. --- drf_braces/fields/_fields.py | 1 - drf_braces/fields/custom.py | 7 +++++++ drf_braces/tests/fields/test_custom.py | 2 ++ drf_braces/tests/fields/test_modified.py | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/drf_braces/fields/_fields.py b/drf_braces/fields/_fields.py index 559fe92..28059de 100644 --- a/drf_braces/fields/_fields.py +++ b/drf_braces/fields/_fields.py @@ -26,7 +26,6 @@ 'MultipleChoiceField', 'NullBooleanField', 'RegexField', - 'RoundedDecimalField', 'SlugField', 'TimeField', 'URLField', diff --git a/drf_braces/fields/custom.py b/drf_braces/fields/custom.py index 35e0b9e..72636dc 100644 --- a/drf_braces/fields/custom.py +++ b/drf_braces/fields/custom.py @@ -80,7 +80,14 @@ def __init__(self, max_digits=100, decimal_places=2, *args, **kwargs): *args, **kwargs ) + def quantize(self, data): + if isinstance(data, float): + return round(data, self.decimal_places) + return super(fields.DecimalField, self).quantize(data) + def to_internal_value(self, data): + if isinstance(data, float): + return self.quantize(data) return self.quantize(super(RoundedDecimalField, self).to_internal_value(data)) def validate_precision(self, data): diff --git a/drf_braces/tests/fields/test_custom.py b/drf_braces/tests/fields/test_custom.py index f978c41..49a11f0 100644 --- a/drf_braces/tests/fields/test_custom.py +++ b/drf_braces/tests/fields/test_custom.py @@ -70,3 +70,5 @@ def test_to_internal_value(self): self.assertEqual(field.to_internal_value(Decimal('5.2345')), Decimal('5.23')) self.assertEqual(field.to_internal_value(Decimal('5.2356')), Decimal('5.24')) self.assertEqual(field.to_internal_value(Decimal('4.2399')), Decimal('4.24')) + self.assertEqual(field.to_internal_value(4.2399), 4.24) + self.assertEqual(field.to_internal_value(5.2345), 5.23) diff --git a/drf_braces/tests/fields/test_modified.py b/drf_braces/tests/fields/test_modified.py index 8e5671d..7514a96 100644 --- a/drf_braces/tests/fields/test_modified.py +++ b/drf_braces/tests/fields/test_modified.py @@ -26,6 +26,7 @@ def test_init(self): def test_quantize(self): field = DecimalField() self.assertIsNone(field.quantize(None)) + self.assertEqual(field.quantize(5.123), 5.123) field = DecimalField(max_digits=4, decimal_places=3) self.assertEqual(field.quantize(Decimal('5.1234567')), Decimal('5.123')) From a0862f8f7d7fa31056fb8534f468f603747a765c Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Wed, 26 Apr 2017 11:46:19 -0400 Subject: [PATCH 03/13] Writing rounded decimal to work more like decimal. --- drf_braces/fields/custom.py | 16 ++++++---------- drf_braces/tests/fields/test_custom.py | 15 ++++++++++----- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drf_braces/fields/custom.py b/drf_braces/fields/custom.py index 72636dc..fe23d09 100644 --- a/drf_braces/fields/custom.py +++ b/drf_braces/fields/custom.py @@ -73,22 +73,18 @@ class RoundedDecimalField(fields.DecimalField): to two decimal places. """ - def __init__(self, max_digits=100, decimal_places=2, *args, **kwargs): - super(fields.DecimalField, self).__init__( + def __init__(self, max_digits=None, decimal_places=2, *args, **kwargs): + super(RoundedDecimalField, self).__init__( max_digits=max_digits, decimal_places=decimal_places, *args, **kwargs ) - def quantize(self, data): - if isinstance(data, float): - return round(data, self.decimal_places) - return super(fields.DecimalField, self).quantize(data) + def quantize(self, value): + if self.max_digits is None and isinstance(value, float): + return round(value, self.decimal_places) - def to_internal_value(self, data): - if isinstance(data, float): - return self.quantize(data) - return self.quantize(super(RoundedDecimalField, self).to_internal_value(data)) + return super(RoundedDecimalField, self).quantize(value) def validate_precision(self, data): return data diff --git a/drf_braces/tests/fields/test_custom.py b/drf_braces/tests/fields/test_custom.py index 49a11f0..fbe8d9e 100644 --- a/drf_braces/tests/fields/test_custom.py +++ b/drf_braces/tests/fields/test_custom.py @@ -59,16 +59,21 @@ def test_to_internal_value(self): self.assertEqual(field.to_internal_value('haha'), 'haha') -class TestCurrencyField(unittest.TestCase): +class TestRoundedField(unittest.TestCase): def test_init(self): field = RoundedDecimalField() - self.assertIsNotNone(field.max_digits) + self.assertIsNone(field.max_digits) self.assertEqual(field.decimal_places, 2) def test_to_internal_value(self): field = RoundedDecimalField() self.assertEqual(field.to_internal_value(Decimal('5.2345')), Decimal('5.23')) self.assertEqual(field.to_internal_value(Decimal('5.2356')), Decimal('5.24')) - self.assertEqual(field.to_internal_value(Decimal('4.2399')), Decimal('4.24')) - self.assertEqual(field.to_internal_value(4.2399), 4.24) - self.assertEqual(field.to_internal_value(5.2345), 5.23) + self.assertEqual(field.to_internal_value(4.2399), Decimal('4.24')) + + def test_quantize(self): + field = RoundedDecimalField() + self.assertEqual(field.quantize(Decimal('5.2356')), Decimal('5.24')) + self.assertEqual(field.quantize(Decimal('4.2399')), Decimal('4.24')) + self.assertEqual(field.quantize(4.2399), 4.24) + self.assertEqual(field.quantize(5.2345), 5.23) From 7dc4d4f8bc063fc6dd90035357b9243c5e0a8bbe Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Tue, 2 May 2017 11:34:29 -0400 Subject: [PATCH 04/13] Reverting importanize on all. --- drf_braces/fields/mixins.py | 2 +- drf_braces/forms/fields.py | 2 +- drf_braces/forms/serializer_form.py | 2 +- drf_braces/parsers.py | 2 +- drf_braces/tests/fields/test_modified.py | 2 +- drf_braces/tests/forms/test_fields.py | 4 ++-- drf_braces/tests/forms/test_serializer_form.py | 2 +- drf_braces/tests/test_parsers.py | 2 +- setup.py | 1 + 9 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drf_braces/fields/mixins.py b/drf_braces/fields/mixins.py index 4d81fa1..22f89f7 100644 --- a/drf_braces/fields/mixins.py +++ b/drf_braces/fields/mixins.py @@ -1,6 +1,6 @@ from __future__ import absolute_import, print_function, unicode_literals -import six +import six from rest_framework.fields import CharField, empty diff --git a/drf_braces/forms/fields.py b/drf_braces/forms/fields.py index d105564..b908ef0 100644 --- a/drf_braces/forms/fields.py +++ b/drf_braces/forms/fields.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, print_function, unicode_literals + import six from dateutil.parser import parse - from django import forms from rest_framework import ISO_8601 diff --git a/drf_braces/forms/serializer_form.py b/drf_braces/forms/serializer_form.py index 9b0ee69..0b4e56c 100644 --- a/drf_braces/forms/serializer_form.py +++ b/drf_braces/forms/serializer_form.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, print_function, unicode_literals import inspect -import six +import six from django import forms from django.forms.forms import DeclarativeFieldsMetaclass from rest_framework import serializers diff --git a/drf_braces/parsers.py b/drf_braces/parsers.py index 55f10dc..a3087cc 100644 --- a/drf_braces/parsers.py +++ b/drf_braces/parsers.py @@ -1,8 +1,8 @@ from __future__ import absolute_import, print_function, unicode_literals import json -import six from collections import OrderedDict +import six from django.conf import settings from rest_framework import parsers diff --git a/drf_braces/tests/fields/test_modified.py b/drf_braces/tests/fields/test_modified.py index 66d5d97..8869d5a 100644 --- a/drf_braces/tests/fields/test_modified.py +++ b/drf_braces/tests/fields/test_modified.py @@ -1,8 +1,8 @@ from __future__ import absolute_import, print_function, unicode_literals -import pytz import unittest from decimal import Decimal +import pytz from django.test.utils import override_settings from drf_braces.fields.modified import BooleanField, DateTimeField, DecimalField diff --git a/drf_braces/tests/forms/test_fields.py b/drf_braces/tests/forms/test_fields.py index 482c599..7905f92 100644 --- a/drf_braces/tests/forms/test_fields.py +++ b/drf_braces/tests/forms/test_fields.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, print_function, unicode_literals -import pytz import unittest from datetime import datetime -from dateutil.tz import tzoffset +import pytz +from dateutil.tz import tzoffset from django import forms from rest_framework import ISO_8601 diff --git a/drf_braces/tests/forms/test_serializer_form.py b/drf_braces/tests/forms/test_serializer_form.py index f59c4b5..236f949 100644 --- a/drf_braces/tests/forms/test_serializer_form.py +++ b/drf_braces/tests/forms/test_serializer_form.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, print_function, unicode_literals -import six import unittest from datetime import datetime import mock +import six from django import forms from rest_framework import serializers diff --git a/drf_braces/tests/test_parsers.py b/drf_braces/tests/test_parsers.py index d4a1e04..3db3fb1 100644 --- a/drf_braces/tests/test_parsers.py +++ b/drf_braces/tests/test_parsers.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, print_function, unicode_literals import json -import six import unittest from collections import OrderedDict +import six from rest_framework import parsers from drf_braces.parsers import SortedJSONParser, StrippingJSONParser diff --git a/setup.py b/setup.py index f8e21c2..872ba85 100755 --- a/setup.py +++ b/setup.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import print_function, unicode_literals import os + from setuptools import find_packages, setup from drf_braces import __author__, __version__ From 45470219f9256634268218e8ba84936f17415c0c Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Tue, 2 May 2017 11:36:40 -0400 Subject: [PATCH 05/13] Importanize revert. --- drf_braces/serializers/form_serializer.py | 2 +- drf_braces/tests/fields/test_modified.py | 1 - drf_braces/tests/serializers/test_form_serialzier.py | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/drf_braces/serializers/form_serializer.py b/drf_braces/serializers/form_serializer.py index 9b9373d..4ce9511 100644 --- a/drf_braces/serializers/form_serializer.py +++ b/drf_braces/serializers/form_serializer.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, print_function, unicode_literals -import six from collections import OrderedDict +import six from django import forms from rest_framework import serializers diff --git a/drf_braces/tests/fields/test_modified.py b/drf_braces/tests/fields/test_modified.py index 8869d5a..09534cc 100644 --- a/drf_braces/tests/fields/test_modified.py +++ b/drf_braces/tests/fields/test_modified.py @@ -26,7 +26,6 @@ def test_init(self): def test_quantize(self): field = DecimalField() self.assertIsNone(field.quantize(None)) - self.assertEqual(field.quantize(5.123), 5.123) field = DecimalField(max_digits=4, decimal_places=3) self.assertEqual(field.quantize(Decimal('5.1234567')), Decimal('5.123')) diff --git a/drf_braces/tests/serializers/test_form_serialzier.py b/drf_braces/tests/serializers/test_form_serialzier.py index 71af6ef..e378e8b 100644 --- a/drf_braces/tests/serializers/test_form_serialzier.py +++ b/drf_braces/tests/serializers/test_form_serialzier.py @@ -1,10 +1,10 @@ from __future__ import absolute_import, print_function, unicode_literals -import six import unittest from collections import OrderedDict from datetime import datetime import mock +import six from django import forms from rest_framework import fields, serializers From 4bb49c8931e3f6d1399e2e5b2ac6bfa4233029c4 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Wed, 3 May 2017 14:15:12 -0400 Subject: [PATCH 06/13] Addressed PR comments. --- drf_braces/fields/custom.py | 24 ------------------------ drf_braces/tests/fields/test_custom.py | 1 - 2 files changed, 25 deletions(-) diff --git a/drf_braces/fields/custom.py b/drf_braces/fields/custom.py index 73dc02f..8905a6d 100644 --- a/drf_braces/fields/custom.py +++ b/drf_braces/fields/custom.py @@ -70,31 +70,7 @@ class RoundedDecimalField(fields.DecimalField): to two decimal places. """ - def __init__(self, max_digits=None, decimal_places=2, *args, **kwargs): - max_digits = max_digits or self.MAX_STRING_LENGTH - super(RoundedDecimalField, self).__init__( - max_digits=max_digits, - decimal_places=decimal_places, - *args, **kwargs - ) - - def to_internal_value(self, data): - return self.quantize(super(RoundedDecimalField, self).to_internal_value(data)) - - def validate_precision(self, data): - return data - - -class RoundedDecimalField(fields.DecimalField): - """ - Currency field subclass of Decimal used for rounding currencies - to two decimal places. - """ - rounding = None - def __init__(self, max_digits=None, decimal_places=2, rounding=None, *args, **kwargs): - max_digits = max_digits or self.MAX_STRING_LENGTH - self.rounding = rounding super(RoundedDecimalField, self).__init__( diff --git a/drf_braces/tests/fields/test_custom.py b/drf_braces/tests/fields/test_custom.py index 3d4861d..473f14f 100644 --- a/drf_braces/tests/fields/test_custom.py +++ b/drf_braces/tests/fields/test_custom.py @@ -62,7 +62,6 @@ def test_to_internal_value(self): class TestRoundedDecimalField(unittest.TestCase): def test_init(self): field = RoundedDecimalField() - self.assertIsNotNone(field.max_digits) self.assertEqual(field.decimal_places, 2) def test_to_internal_value(self): From 6df610ab509eecc7002b034ef3e6f5e118a4acfb Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Fri, 5 May 2017 11:08:10 -0400 Subject: [PATCH 07/13] Ran newer importanize. --- drf_braces/fields/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drf_braces/fields/custom.py b/drf_braces/fields/custom.py index 8905a6d..1a8b486 100644 --- a/drf_braces/fields/custom.py +++ b/drf_braces/fields/custom.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, print_function, unicode_literals import inspect import pytz -import six from decimal import Decimal, getcontext +import six from django.utils.translation import gettext as _ from . import _fields as fields From d000ab10f48bc32716df858210a0dc70cf94e0b6 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Fri, 5 May 2017 11:36:02 -0400 Subject: [PATCH 08/13] More importanize. --- drf_braces/forms/fields.py | 2 +- drf_braces/tests/fields/test_modified.py | 2 +- drf_braces/tests/forms/test_fields.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drf_braces/forms/fields.py b/drf_braces/forms/fields.py index b908ef0..2c1e3ed 100644 --- a/drf_braces/forms/fields.py +++ b/drf_braces/forms/fields.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, print_function, unicode_literals +from dateutil.parser import parse import six -from dateutil.parser import parse from django import forms from rest_framework import ISO_8601 diff --git a/drf_braces/tests/fields/test_modified.py b/drf_braces/tests/fields/test_modified.py index 09534cc..3303e87 100644 --- a/drf_braces/tests/fields/test_modified.py +++ b/drf_braces/tests/fields/test_modified.py @@ -1,8 +1,8 @@ from __future__ import absolute_import, print_function, unicode_literals +import pytz import unittest from decimal import Decimal -import pytz from django.test.utils import override_settings from drf_braces.fields.modified import BooleanField, DateTimeField, DecimalField diff --git a/drf_braces/tests/forms/test_fields.py b/drf_braces/tests/forms/test_fields.py index 7905f92..482c599 100644 --- a/drf_braces/tests/forms/test_fields.py +++ b/drf_braces/tests/forms/test_fields.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, print_function, unicode_literals +import pytz import unittest from datetime import datetime - -import pytz from dateutil.tz import tzoffset + from django import forms from rest_framework import ISO_8601 From d7f9e2042d955651847fa9e8305250b0e9ff47e7 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Fri, 5 May 2017 11:46:20 -0400 Subject: [PATCH 09/13] Fixing build issues. --- drf_braces/fields/custom.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drf_braces/fields/custom.py b/drf_braces/fields/custom.py index 1a8b486..7d1fdf5 100644 --- a/drf_braces/fields/custom.py +++ b/drf_braces/fields/custom.py @@ -90,7 +90,7 @@ def quantize(self, data): Quantize the decimal value to the configured precision. """ if self.decimal_places is None: - return value + return data context = getcontext().copy() @@ -103,5 +103,6 @@ def quantize(self, data): context=context ) + __all__ = [name for name, value in locals().items() if inspect.isclass(value) and issubclass(value, fields.Field)] From da6205d9af9fd16ade233f422284d56d2cad7323 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Fri, 5 May 2017 12:24:09 -0400 Subject: [PATCH 10/13] NEW IMPORTANCE ENV IMPORTANIZING. --- drf_braces/fields/custom.py | 2 +- drf_braces/forms/fields.py | 2 +- drf_braces/tests/fields/test_custom.py | 2 +- drf_braces/tests/fields/test_modified.py | 2 +- drf_braces/tests/forms/test_fields.py | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drf_braces/fields/custom.py b/drf_braces/fields/custom.py index 7d1fdf5..af6acfc 100644 --- a/drf_braces/fields/custom.py +++ b/drf_braces/fields/custom.py @@ -1,8 +1,8 @@ from __future__ import absolute_import, print_function, unicode_literals import inspect -import pytz from decimal import Decimal, getcontext +import pytz import six from django.utils.translation import gettext as _ diff --git a/drf_braces/forms/fields.py b/drf_braces/forms/fields.py index 2c1e3ed..b908ef0 100644 --- a/drf_braces/forms/fields.py +++ b/drf_braces/forms/fields.py @@ -1,7 +1,7 @@ from __future__ import absolute_import, print_function, unicode_literals -from dateutil.parser import parse import six +from dateutil.parser import parse from django import forms from rest_framework import ISO_8601 diff --git a/drf_braces/tests/fields/test_custom.py b/drf_braces/tests/fields/test_custom.py index 473f14f..b86400f 100644 --- a/drf_braces/tests/fields/test_custom.py +++ b/drf_braces/tests/fields/test_custom.py @@ -1,10 +1,10 @@ from __future__ import absolute_import, print_function, unicode_literals -import pytz import unittest from collections import OrderedDict from decimal import ROUND_DOWN, Decimal import mock +import pytz from drf_braces.fields.custom import ( NonValidatingChoiceField, diff --git a/drf_braces/tests/fields/test_modified.py b/drf_braces/tests/fields/test_modified.py index 3303e87..09534cc 100644 --- a/drf_braces/tests/fields/test_modified.py +++ b/drf_braces/tests/fields/test_modified.py @@ -1,8 +1,8 @@ from __future__ import absolute_import, print_function, unicode_literals -import pytz import unittest from decimal import Decimal +import pytz from django.test.utils import override_settings from drf_braces.fields.modified import BooleanField, DateTimeField, DecimalField diff --git a/drf_braces/tests/forms/test_fields.py b/drf_braces/tests/forms/test_fields.py index 482c599..7905f92 100644 --- a/drf_braces/tests/forms/test_fields.py +++ b/drf_braces/tests/forms/test_fields.py @@ -1,9 +1,9 @@ from __future__ import absolute_import, print_function, unicode_literals -import pytz import unittest from datetime import datetime -from dateutil.tz import tzoffset +import pytz +from dateutil.tz import tzoffset from django import forms from rest_framework import ISO_8601 From baa298bef687307a39d562c3ced0b51c2cb3f627 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Fri, 5 May 2017 12:31:13 -0400 Subject: [PATCH 11/13] Adding rounding check. --- drf_braces/tests/fields/test_custom.py | 1 + 1 file changed, 1 insertion(+) diff --git a/drf_braces/tests/fields/test_custom.py b/drf_braces/tests/fields/test_custom.py index b86400f..51760eb 100644 --- a/drf_braces/tests/fields/test_custom.py +++ b/drf_braces/tests/fields/test_custom.py @@ -63,6 +63,7 @@ class TestRoundedDecimalField(unittest.TestCase): def test_init(self): field = RoundedDecimalField() self.assertEqual(field.decimal_places, 2) + self.assertEqual(field.rounding, None) def test_to_internal_value(self): field = RoundedDecimalField() From 3525ee15e0a0d9c525b28a348c2c55bf59642a39 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Fri, 5 May 2017 12:33:09 -0400 Subject: [PATCH 12/13] More rounding test. --- drf_braces/tests/fields/test_custom.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drf_braces/tests/fields/test_custom.py b/drf_braces/tests/fields/test_custom.py index 51760eb..8fb3aad 100644 --- a/drf_braces/tests/fields/test_custom.py +++ b/drf_braces/tests/fields/test_custom.py @@ -65,6 +65,9 @@ def test_init(self): self.assertEqual(field.decimal_places, 2) self.assertEqual(field.rounding, None) + new_field = RoundedDecimalField(rounding=ROUND_DOWN) + self.assertEqual(new_field.rounding, ROUND_DOWN) + def test_to_internal_value(self): field = RoundedDecimalField() self.assertEqual(field.to_internal_value(5), Decimal('5')) From e4ea7c41979fbe55e2686df8acb6cd6aab1f1613 Mon Sep 17 00:00:00 2001 From: Marc Marta Date: Fri, 5 May 2017 12:36:13 -0400 Subject: [PATCH 13/13] Assert is None. --- drf_braces/tests/fields/test_custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drf_braces/tests/fields/test_custom.py b/drf_braces/tests/fields/test_custom.py index 8fb3aad..e9f9980 100644 --- a/drf_braces/tests/fields/test_custom.py +++ b/drf_braces/tests/fields/test_custom.py @@ -63,7 +63,7 @@ class TestRoundedDecimalField(unittest.TestCase): def test_init(self): field = RoundedDecimalField() self.assertEqual(field.decimal_places, 2) - self.assertEqual(field.rounding, None) + self.assertIsNone(field.rounding) new_field = RoundedDecimalField(rounding=ROUND_DOWN) self.assertEqual(new_field.rounding, ROUND_DOWN)