diff options
author | Eric Smith <eric@trueblade.com> | 2007-09-01 10:56:01 +0000 |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2007-09-01 10:56:01 +0000 |
commit | 37f10386f1bedb992f3d9770b2f71b5edda2abbe (patch) | |
tree | 7c258bc40124636d938c6f7d61840c29fb7952cd /Lib/test/test_builtin.py | |
parent | a95207ab3bce39b8278fc479d1d391365ffc7a7c (diff) | |
download | cpython-git-37f10386f1bedb992f3d9770b2f71b5edda2abbe.tar.gz |
Changed to use 'U' argument to PyArg_ParseTuple, instead of manually checking for unicode objects.
Diffstat (limited to 'Lib/test/test_builtin.py')
-rw-r--r-- | Lib/test/test_builtin.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 1a9781b7d7..d9633af473 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -525,10 +525,15 @@ class BuiltinTest(unittest.TestCase): return str(self.x) + format_spec # class that returns a bad type from __format__ - class H: + class B: def __format__(self, format_spec): return 1.0 + # class that is derived from string, used + # as a format spec + class C(str): + pass + self.assertEqual(format(3, ''), '3') self.assertEqual(format(A(3), 'spec'), '3spec') @@ -550,7 +555,10 @@ class BuiltinTest(unittest.TestCase): empty_format_spec(None) # TypeError because self.__format__ returns the wrong type - self.assertRaises(TypeError, format, H(), "") + self.assertRaises(TypeError, format, B(), "") + + # make sure we can take a subclass of str as a format spec + self.assertEqual(format(0, C('10')), ' 0') def test_getattr(self): import sys |