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
641e7963
Commit
641e7963
authored
Jan 05, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_bytes: test PyBytes_FromFormat() using ctypes
parent
b3486edd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
Lib/test/test_bytes.py
Lib/test/test_bytes.py
+21
-0
No files found.
Lib/test/test_bytes.py
View file @
641e7963
...
...
@@ -497,6 +497,27 @@ class BytesTest(BaseBytesTest):
return
None
self
.
assertRaises
(
TypeError
,
bytes
,
A
())
# Test PyBytes_FromFormat()
def
test_from_format
(
self
):
test
.
support
.
import_module
(
'ctypes'
)
from
ctypes
import
pythonapi
,
py_object
,
c_int
,
c_char_p
PyBytes_FromFormat
=
pythonapi
.
PyBytes_FromFormat
PyBytes_FromFormat
.
restype
=
py_object
self
.
assertEqual
(
PyBytes_FromFormat
(
b'format'
),
b'format'
)
self
.
assertEqual
(
PyBytes_FromFormat
(
b'%'
),
b'%'
)
self
.
assertEqual
(
PyBytes_FromFormat
(
b'%%'
),
b'%'
)
self
.
assertEqual
(
PyBytes_FromFormat
(
b'%%s'
),
b'%s'
)
self
.
assertEqual
(
PyBytes_FromFormat
(
b'[%%]'
),
b'[%]'
)
self
.
assertEqual
(
PyBytes_FromFormat
(
b'%%%c'
,
c_int
(
ord
(
'_'
))),
b'%_'
)
self
.
assertEqual
(
PyBytes_FromFormat
(
b'c:%c'
,
c_int
(
255
)),
b'c:
\
xff
'
)
self
.
assertEqual
(
PyBytes_FromFormat
(
b's:%s'
,
c_char_p
(
b'cstr'
)),
b's:cstr'
)
class
ByteArrayTest
(
BaseBytesTest
):
type2test
=
bytearray
...
...
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