diff options
author | Eric Smith <eric@trueblade.com> | 2007-09-01 10:56:01 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2007-09-01 10:56:01 (GMT) |
commit | 37f10386f1bedb992f3d9770b2f71b5edda2abbe (patch) | |
tree | 7c258bc40124636d938c6f7d61840c29fb7952cd /Lib | |
parent | a95207ab3bce39b8278fc479d1d391365ffc7a7c (diff) | |
download | cpython-37f10386f1bedb992f3d9770b2f71b5edda2abbe.zip cpython-37f10386f1bedb992f3d9770b2f71b5edda2abbe.tar.gz cpython-37f10386f1bedb992f3d9770b2f71b5edda2abbe.tar.bz2 |
Changed to use 'U' argument to PyArg_ParseTuple, instead of manually checking for unicode objects.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_builtin.py | 12 | ||||
-rw-r--r-- | Lib/test/test_unicode.py | 3 |
2 files changed, 10 insertions, 5 deletions
diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 1a9781b..d9633af 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 diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 444656a..6773f2a 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -581,9 +581,6 @@ class UnicodeTest( self.assertRaises(ValueError, format, "", "-") self.assertRaises(ValueError, "{0:=s}".format, '') - # check that __format__ returns a string - #self.assertRaises(TypeError, "{0}".format, H()) - def test_formatting(self): string_tests.MixinStrUnicodeUserStringTest.test_formatting(self) # Testing Unicode formatting strings... |