Mercurial > cpython-lru_cache-weakref
diff Lib/test/test_float.py @ 53161:df2638b9bee2 3.0
Merged revisions 71628 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r71628 | benjamin.peterson | 2009-04-15 16:34:27 -0500 (Wed, 15 Apr 2009) | 11 lines
Merged revisions 71627 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r71627 | benjamin.peterson | 2009-04-15 16:26:36 -0500 (Wed, 15 Apr 2009) | 4 lines
call __float__ on str subclasses #5759
tests by R. David Murray
........
................
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Wed, 15 Apr 2009 21:40:50 +0000 |
| parents | 98628dc730da |
| children | e9edcaf42547 b653eab13b73 |
line wrap: on
line diff
--- a/Lib/test/test_float.py Tue Apr 14 08:00:41 2009 +0000 +++ b/Lib/test/test_float.py Wed Apr 15 21:40:50 2009 +0000 @@ -78,11 +78,18 @@ def __float__(self): return 42 + # Issue 5759: __float__ not called on str subclasses (though it is on + # unicode subclasses). + class FooStr(str): + def __float__(self): + return float(str(self)) + 1 + self.assertAlmostEqual(float(Foo0()), 42.) self.assertAlmostEqual(float(Foo1()), 42.) self.assertAlmostEqual(float(Foo2()), 42.) self.assertAlmostEqual(float(Foo3(21)), 42.) self.assertRaises(TypeError, float, Foo4(42)) + self.assertAlmostEqual(float(FooStr('8')), 9.) def test_floatasratio(self): for f, ratio in [
