diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-26 17:50:34 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-02-26 17:50:34 +0000 |
| commit | 2d95ef1f252b2752a3840e84a01d989af9921033 (patch) | |
| tree | f7a9086dc5fed65ef4cc658a5c5d9742bcc58077 /test/dialect/test_postgresql.py | |
| parent | 11f996da20cf40692a21f6e836655cc36d1857d7 (diff) | |
| download | sqlalchemy-2d95ef1f252b2752a3840e84a01d989af9921033.tar.gz | |
- the "scale" argument of the Numeric() type is honored when
coercing a returned floating point value into a string
on its way to Decimal - this allows accuracy to function
on SQLite, MySQL. [ticket:1717]
Diffstat (limited to 'test/dialect/test_postgresql.py')
| -rw-r--r-- | test/dialect/test_postgresql.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/test/dialect/test_postgresql.py b/test/dialect/test_postgresql.py index 1a21ec11f..b002e7f19 100644 --- a/test/dialect/test_postgresql.py +++ b/test/dialect/test_postgresql.py @@ -9,6 +9,7 @@ from sqlalchemy import exc, schema, types from sqlalchemy.dialects.postgresql import base as postgresql from sqlalchemy.engine.strategies import MockEngineStrategy from sqlalchemy.test import * +from sqlalchemy.test.util import round_decimal from sqlalchemy.sql import table, column from sqlalchemy.test.testing import eq_ from test.engine._base import TablesTest @@ -203,15 +204,6 @@ class FloatCoercionTest(TablesTest, AssertsExecutionResults): {'data':9}, ) - def _round(self, x): - if isinstance(x, float): - return round(x, 9) - elif isinstance(x, decimal.Decimal): - # really ? - # (can also use shift() here but that is 2.6 only) - x = (x * decimal.Decimal("1000000000")).to_integral() / pow(10, 9) - return x - @testing.resolve_artifact_names def test_float_coercion(self): for type_, result in [ @@ -226,14 +218,14 @@ class FloatCoercionTest(TablesTest, AssertsExecutionResults): ]) ).scalar() - eq_(self._round(ret), result) + eq_(round_decimal(ret, 9), result) ret = testing.db.execute( select([ cast(func.stddev_pop(data_table.c.data), type_) ]) ).scalar() - eq_(self._round(ret), result) + eq_(round_decimal(ret, 9), result) |
