Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
739e2ad6
Commit
739e2ad6
authored
Aug 27, 2007
by
Eric Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Additional test for formatting code.
parent
9c62772d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+2
-1
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+9
-3
No files found.
Lib/test/test_builtin.py
View file @
739e2ad6
...
...
@@ -541,7 +541,8 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
format
(
-
3.1415e-104
,
""
),
str
(
-
3.1415e-104
))
self
.
assertEqual
(
format
(
object
,
""
),
str
(
object
))
#self.assertRaises(TypeError, format, H(), "")
# TypeError because self.__format__ returns the wrong type
self
.
assertRaises
(
TypeError
,
format
,
H
(),
""
)
def
test_getattr
(
self
):
import
sys
...
...
Lib/test/test_unicode.py
View file @
739e2ad6
...
...
@@ -424,6 +424,10 @@ class UnicodeTest(
def
__format__
(
self
,
format_spec
):
return
1.0
class
I
(
datetime
.
date
):
def
__format__
(
self
,
format_spec
):
return
self
.
strftime
(
format_spec
)
self
.
assertEqual
(
''
.
format
(),
''
)
self
.
assertEqual
(
'abc'
.
format
(),
'abc'
)
...
...
@@ -504,9 +508,6 @@ class UnicodeTest(
self
.
assertEqual
(
'{0!r:}'
.
format
(
'Hello'
),
"'Hello'"
)
self
.
assertEqual
(
'{0!r}'
.
format
(
F
(
'Hello'
)),
'F(Hello)'
)
# XXX should pass, but currently don't
# format(object, "")
# test fallback to object.__format__
self
.
assertEqual
(
'{0}'
.
format
({}),
'{}'
)
self
.
assertEqual
(
'{0}'
.
format
([]),
'[]'
)
...
...
@@ -518,6 +519,11 @@ class UnicodeTest(
self
.
assertEqual
(
'{0:>15s}'
.
format
(
G
(
'data'
)),
' string is data'
)
self
.
assertEqual
(
'{0!s}'
.
format
(
G
(
'data'
)),
'string is data'
)
self
.
assertEqual
(
"{0:date: %Y-%m-%d}"
.
format
(
I
(
year
=
2007
,
month
=
8
,
day
=
27
)),
"date: 2007-08-27"
)
# string format specifiers
self
.
assertEqual
(
'{0:}'
.
format
(
'a'
),
'a'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment