Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
circuitpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
circuitpython
Commits
ecb4357f
Commit
ecb4357f
authored
Mar 15, 2017
by
Damien George
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests/basics: Move string-modulo-format int tests to dedicated file.
parent
b154468b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
32 deletions
+34
-32
tests/basics/string_format_modulo.py
tests/basics/string_format_modulo.py
+0
-32
tests/basics/string_format_modulo_int.py
tests/basics/string_format_modulo_int.py
+34
-0
No files found.
tests/basics/string_format_modulo.py
View file @
ecb4357f
...
...
@@ -33,38 +33,6 @@ print("%c" % 48)
print
(
"%c"
%
'a'
)
print
(
"%10s"
%
'abc'
)
print
(
"%-10s"
%
'abc'
)
print
(
"%d"
%
10
)
print
(
"%+d"
%
10
)
print
(
"% d"
%
10
)
print
(
"%d"
%
-
10
)
print
(
"%d"
%
True
)
print
(
"%i"
%
-
10
)
print
(
"%i"
%
True
)
print
(
"%u"
%
-
10
)
print
(
"%u"
%
True
)
print
(
"%x"
%
18
)
print
(
"%o"
%
18
)
print
(
"%X"
%
18
)
print
(
"%#x"
%
18
)
print
(
"%#X"
%
18
)
print
(
"%#6o"
%
18
)
print
(
"%#6x"
%
18
)
print
(
"%#06x"
%
18
)
print
(
"%*d"
%
(
5
,
10
))
print
(
"%*.*d"
%
(
2
,
2
,
20
))
print
(
"%*.*d"
%
(
5
,
8
,
20
))
print
(
">%8.4d<"
%
-
12
)
print
(
">% 8.4d<"
%
-
12
)
print
(
">%+8.4d<"
%
12
)
print
(
">%+8.4d<"
%
-
12
)
print
(
">%08.4d<"
%
-
12
)
print
(
">%08.4d<"
%
12
)
print
(
">%-8.4d<"
%
-
12
)
print
(
">%-08.4d<"
%
-
12
)
print
(
">%-+08.4d<"
%
-
12
)
print
(
">%-+08.4d<"
%
12
)
# Should be able to print dicts; in this case they aren't used
# to lookup keywords in formats like %(foo)s
...
...
tests/basics/string_format_modulo_int.py
View file @
ecb4357f
# test string modulo formatting with int values
# basic cases
print
(
"%d"
%
10
)
print
(
"%+d"
%
10
)
print
(
"% d"
%
10
)
print
(
"%d"
%
-
10
)
print
(
"%d"
%
True
)
print
(
"%i"
%
-
10
)
print
(
"%i"
%
True
)
print
(
"%u"
%
-
10
)
print
(
"%u"
%
True
)
print
(
"%x"
%
18
)
print
(
"%o"
%
18
)
print
(
"%X"
%
18
)
print
(
"%#x"
%
18
)
print
(
"%#X"
%
18
)
print
(
"%#6o"
%
18
)
print
(
"%#6x"
%
18
)
print
(
"%#06x"
%
18
)
# with *
print
(
"%*d"
%
(
5
,
10
))
print
(
"%*.*d"
%
(
2
,
2
,
20
))
print
(
"%*.*d"
%
(
5
,
8
,
20
))
# precision
for
val
in
(
-
12
,
12
):
print
(
">%8.4d<"
%
val
)
print
(
">% 8.4d<"
%
val
)
print
(
">%+8.4d<"
%
val
)
print
(
">%08.4d<"
%
val
)
print
(
">%-8.4d<"
%
val
)
print
(
">%-08.4d<"
%
val
)
print
(
">%-+08.4d<"
%
val
)
# test + option with various amount of padding
for
pad
in
(
''
,
' '
,
'0'
):
for
n
in
(
1
,
2
,
3
):
...
...
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