diff options
author | Eric Smith <eric@trueblade.com> | 2007-08-30 22:23:08 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2007-08-30 22:23:08 (GMT) |
commit | 185e30cdf330b0c687a7afaf26b1eef761ff12ca (patch) | |
tree | 207ffc5193da7731b951d1e7e6819940517551f4 /Lib/test/test_unicode.py | |
parent | bc3b345f8284620bba07e9c2ec4cd64553f2b983 (diff) | |
download | cpython-185e30cdf330b0c687a7afaf26b1eef761ff12ca.zip cpython-185e30cdf330b0c687a7afaf26b1eef761ff12ca.tar.gz cpython-185e30cdf330b0c687a7afaf26b1eef761ff12ca.tar.bz2 |
Added format tests.
Fixed bug in alignment of negative numbers.
Whitespace normalization.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r-- | Lib/test/test_unicode.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 47d7236..444656a 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -379,8 +379,6 @@ class UnicodeTest( self.assertEqual("The year is {0.year}".format(d), "The year is 2007") - #"{0!r:20}".format("Hello") - # classes we'll use for testing class C: def __init__(self, x=100): @@ -428,6 +426,10 @@ class UnicodeTest( def __format__(self, format_spec): return self.strftime(format_spec) + class J(int): + def __format__(self, format_spec): + return int.__format__(self * 2, format_spec) + self.assertEqual(''.format(), '') self.assertEqual('abc'.format(), 'abc') @@ -465,12 +467,6 @@ class UnicodeTest( self.assertEqual('{0[1][0]}'.format(['abc', ['def']]), 'def') self.assertEqual('{0[1][0].x}'.format(['abc', [D('def')]]), 'def') - # I'm not sure if this should work, or if it's a problem if it does work - #'{0[_{foo}]}'.format({'_FOO': 'abc'}, foo='FOO') - #('{0[{foo}{bar}]}'.format({'FOOBAR': 'abc'}, foo='FOO', bar='BAR') - - # format specifiers for built in types - # strings self.assertEqual('{0:.3s}'.format('abc'), 'abc') self.assertEqual('{0:.3s}'.format('ab'), 'ab') @@ -524,6 +520,10 @@ class UnicodeTest( day=27)), "date: 2007-08-27") + # test deriving from a builtin type and overriding __format__ + self.assertEqual("{0}".format(J(10)), "20") + + # string format specifiers self.assertEqual('{0:}'.format('a'), 'a') |