diff options
author | Isaac Jurado <diptongo@gmail.com> | 2015-10-11 14:26:04 +0200 |
---|---|---|
committer | Isaac Jurado <diptongo@gmail.com> | 2015-10-14 19:54:12 +0200 |
commit | fe77bb3e66a7838b119e6b8ca92c2e0396ed84dd (patch) | |
tree | ebaf38db523250c447d61e52f03f068343f0e9ec /tests/test_plural.py | |
parent | b6169be329e121111dc9c3242c3538ee3b0a3aaa (diff) | |
download | babel-fe77bb3e66a7838b119e6b8ca92c2e0396ed84dd.tar.gz |
tests: Use the automatically chosen Decimal class
Now that the babel._compat module can automatically select a faster decimal
implementation if available, be more consistent across the rest of the code when
dealing with Decimal instances.
Diffstat (limited to 'tests/test_plural.py')
-rw-r--r-- | tests/test_plural.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/test_plural.py b/tests/test_plural.py index 278b5db..b0cad8d 100644 --- a/tests/test_plural.py +++ b/tests/test_plural.py @@ -10,10 +10,11 @@ # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. -import decimal import unittest import pytest + from babel import plural +from babel._compat import Decimal def test_plural_rule(): @@ -33,29 +34,29 @@ def test_plural_rule_operands_i(): def test_plural_rule_operands_v(): rule = plural.PluralRule({'one': 'v is 2'}) - assert rule(decimal.Decimal('1.20')) == 'one' - assert rule(decimal.Decimal('1.2')) == 'other' + assert rule(Decimal('1.20')) == 'one' + assert rule(Decimal('1.2')) == 'other' assert rule(2) == 'other' def test_plural_rule_operands_w(): rule = plural.PluralRule({'one': 'w is 2'}) - assert rule(decimal.Decimal('1.23')) == 'one' - assert rule(decimal.Decimal('1.20')) == 'other' + assert rule(Decimal('1.23')) == 'one' + assert rule(Decimal('1.20')) == 'other' assert rule(1.2) == 'other' def test_plural_rule_operands_f(): rule = plural.PluralRule({'one': 'f is 20'}) - assert rule(decimal.Decimal('1.23')) == 'other' - assert rule(decimal.Decimal('1.20')) == 'one' + assert rule(Decimal('1.23')) == 'other' + assert rule(Decimal('1.20')) == 'one' assert rule(1.2) == 'other' def test_plural_rule_operands_t(): rule = plural.PluralRule({'one': 't = 5'}) - assert rule(decimal.Decimal('1.53')) == 'other' - assert rule(decimal.Decimal('1.50')) == 'one' + assert rule(Decimal('1.53')) == 'other' + assert rule(Decimal('1.50')) == 'one' assert rule(1.5) == 'one' @@ -250,6 +251,6 @@ EXTRACT_OPERANDS_TESTS = ( @pytest.mark.parametrize('source,n,i,v,w,f,t', EXTRACT_OPERANDS_TESTS) def test_extract_operands(source, n, i, v, w, f, t): - source = decimal.Decimal(source) if isinstance(source, str) else source + source = Decimal(source) if isinstance(source, str) else source assert (plural.extract_operands(source) == - decimal.Decimal(n), i, v, w, f, t) + Decimal(n), i, v, w, f, t) |