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
8b7664d0
Commit
8b7664d0
authored
May 07, 2011
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Plain Diff
#5421: merge with 3.2.
parents
842e5675
4c1aebd8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
0 deletions
+44
-0
Lib/test/test_socket.py
Lib/test/test_socket.py
+44
-0
No files found.
Lib/test/test_socket.py
View file @
8b7664d0
...
...
@@ -283,6 +283,50 @@ class GeneralModuleTests(unittest.TestCase):
self
.
assertRaises
(
socket
.
error
,
raise_gaierror
,
"Error raising socket exception."
)
def
testSendtoErrors
(
self
):
# Testing that sendto doens't masks failures. See #10169.
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
self
.
addCleanup
(
s
.
close
)
s
.
bind
((
''
,
0
))
sockname
=
s
.
getsockname
()
# 2 args
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
'
\
u2620
'
,
sockname
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"'str' does not support the buffer interface"
)
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
5j
,
sockname
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"'complex' does not support the buffer interface"
)
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
b'foo'
,
None
)
self
.
assertIn
(
'not NoneType'
,
str
(
cm
.
exception
))
# 3 args
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
'
\
u2620
'
,
0
,
sockname
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"'str' does not support the buffer interface"
)
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
5j
,
0
,
sockname
)
self
.
assertEqual
(
str
(
cm
.
exception
),
"'complex' does not support the buffer interface"
)
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
b'foo'
,
0
,
None
)
self
.
assertIn
(
'not NoneType'
,
str
(
cm
.
exception
))
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
b'foo'
,
'bar'
,
sockname
)
self
.
assertIn
(
'an integer is required'
,
str
(
cm
.
exception
))
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
b'foo'
,
None
,
None
)
self
.
assertIn
(
'an integer is required'
,
str
(
cm
.
exception
))
# wrong number of args
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
b'foo'
)
self
.
assertIn
(
'(1 given)'
,
str
(
cm
.
exception
))
with
self
.
assertRaises
(
TypeError
)
as
cm
:
s
.
sendto
(
b'foo'
,
0
,
sockname
,
4
)
self
.
assertIn
(
'(4 given)'
,
str
(
cm
.
exception
))
def
testCrucialConstants
(
self
):
# Testing for mission critical constants
socket
.
AF_INET
...
...
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