From dc0389cca04bf84dbc32ca2c9e1e6d5c3267e51a Mon Sep 17 00:00:00 2001 From: Karen Tracey Date: Sat, 8 Nov 2008 01:53:20 +0000 Subject: [1.0.X] Fixed #5748 -- Made floatformat filter round properly on all platforms and handle NaN input correctly on Windows. Also added tests for these cases. Thanks for the report and initial patch to SmileyChris and PJCrosier. [9369] from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9370 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/defaultfilters/tests.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tests/regressiontests') diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py index 9e360fc061..a97596f4d7 100644 --- a/tests/regressiontests/defaultfilters/tests.py +++ b/tests/regressiontests/defaultfilters/tests.py @@ -13,15 +13,15 @@ u'0.1' u'0.0' >>> floatformat(0.0) u'0' ->>> floatformat(7.7,3) +>>> floatformat(7.7, 3) u'7.700' ->>> floatformat(6.000000,3) +>>> floatformat(6.000000, 3) u'6.000' >>> floatformat(6.200000, 3) u'6.200' >>> floatformat(6.200000, -3) u'6.200' ->>> floatformat(13.1031,-3) +>>> floatformat(13.1031, -3) u'13.103' >>> floatformat(11.1197, -2) u'11.12' @@ -35,10 +35,23 @@ u'8.280' u'' >>> floatformat(13.1031, u'bar') u'13.1031' +>>> floatformat(18.125, 2) +u'18.13' >>> floatformat(u'foo', u'bar') u'' +>>> floatformat(u'¿Cómo esta usted?') +u'' >>> floatformat(None) u'' +>>> pos_inf = float(1e30000) +>>> floatformat(pos_inf) == unicode(pos_inf) +True +>>> neg_inf = float(-1e30000) +>>> floatformat(neg_inf) == unicode(neg_inf) +True +>>> nan = pos_inf / pos_inf +>>> floatformat(nan) == unicode(nan) +True >>> addslashes(u'"double quotes" and \'single quotes\'') u'\\"double quotes\\" and \\\'single quotes\\\'' -- cgit v1.3