Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
9d80ea8e
Commit
9d80ea8e
authored
Dec 13, 2017
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test__ssl under leakchecks. Refactor test__ssl to share more with test__socket.
parent
74e04b49
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
19 deletions
+27
-19
src/greentest/greentest.py
src/greentest/greentest.py
+4
-2
src/greentest/test__makefile_ref.py
src/greentest/test__makefile_ref.py
+0
-3
src/greentest/test__socket.py
src/greentest/test__socket.py
+7
-5
src/greentest/test__ssl.py
src/greentest/test__ssl.py
+16
-9
No files found.
src/greentest/greentest.py
View file @
9d80ea8e
...
...
@@ -254,8 +254,10 @@ def wrap_refcount(method):
d
=
sum
(
hist_before
.
values
())
self
.
setUp
()
method
(
self
,
*
args
,
**
kwargs
)
self
.
tearDown
()
try
:
method
(
self
,
*
args
,
**
kwargs
)
finally
:
self
.
tearDown
()
# Grab post snapshot
if
'urlparse'
in
sys
.
modules
:
...
...
src/greentest/test__makefile_ref.py
View file @
9d80ea8e
...
...
@@ -119,15 +119,12 @@ class Test(greentest.TestCase):
# Keeping raw sockets alive keeps SSL sockets
# from being closed too, at least on CPython, so we
# need to use weakrefs
if
'close_on_teardown'
not
in
self
.
__dict__
:
self
.
close_on_teardown
=
[]
self
.
close_on_teardown
.
append
(
weakref
.
ref
(
resource
))
return
resource
def
_tearDownCloseOnTearDown
(
self
):
self
.
close_on_teardown
=
[
r
()
for
r
in
self
.
close_on_teardown
if
r
()
is
not
None
]
super
(
Test
,
self
).
_tearDownCloseOnTearDown
()
self
.
close_on_teardown
=
[]
class
TestSocket
(
Test
):
...
...
src/greentest/test__socket.py
View file @
9d80ea8e
...
...
@@ -47,8 +47,8 @@ class TestTCP(greentest.TestCase):
def
setUp
(
self
):
super
(
TestTCP
,
self
).
setUp
()
listener
=
socket
.
socket
(
)
self
.
_close_on_teardown
(
listener
)
self
.
listener
=
self
.
_close_on_teardown
(
self
.
_setup_listener
()
)
# XXX: On Windows (at least with libev), if we have a cleanup/tearDown method
# that does 'del self.listener' AND we haven't sometime
# previously closed the listener (while the test body was executing)
...
...
@@ -64,10 +64,12 @@ class TestTCP(greentest.TestCase):
# Perhaps our logic is wrong in libev_vfd in the way we use
# _open_osfhandle and determine we can close it?
greentest
.
bind_and_listen
(
listener
,
(
'127.0.0.1'
,
0
))
self
.
listener
=
listener
self
.
port
=
listener
.
getsockname
()[
1
]
self
.
port
=
self
.
listener
.
getsockname
()[
1
]
def
_setup_listener
(
self
):
listener
=
socket
.
socket
()
greentest
.
bind_and_listen
(
listener
,
(
'127.0.0.1'
,
0
))
return
listener
def
create_connection
(
self
,
host
=
'127.0.0.1'
,
port
=
None
,
timeout
=
None
,
blocking
=
None
):
...
...
src/greentest/test__ssl.py
View file @
9d80ea8e
...
...
@@ -20,10 +20,10 @@ class TestSSL(test__socket.TestTCP):
# See https://bugs.python.org/issue10272
TIMEOUT_ERROR
=
getattr
(
socket
,
'sslerror'
,
socket
.
timeout
)
def
setUp
(
self
):
greentest
.
TestCase
.
setUp
(
self
)
self
.
listener
,
_raw_listener
=
ssl_listener
((
'127.0.0.1'
,
0
),
self
.
privfile
,
self
.
certfile
)
self
.
port
=
self
.
listener
.
getsockname
()[
1
]
def
_setup_listener
(
self
):
listener
,
raw_listener
=
ssl_listener
((
'127.0.0.1'
,
0
),
self
.
privfile
,
self
.
certfile
)
self
.
_close_on_teardown
(
raw_listener
)
return
listener
def
create_connection
(
self
,
*
args
,
**
kwargs
):
return
ssl
.
wrap_socket
(
super
(
TestSSL
,
self
).
create_connection
(
*
args
,
**
kwargs
))
...
...
@@ -50,26 +50,33 @@ class TestSSL(test__socket.TestTCP):
# on non-blocking sockets because it's a simple loop around
# send(). Python 2.6 doesn't have SSLWantWriteError
expected
=
getattr
(
ssl
,
'SSLWantWriteError'
,
ssl
.
SSLError
)
self
.
assertRaises
(
expected
,
client
.
sendall
,
self
.
_test_sendall_data
)
with
self
.
assertRaises
(
expected
):
client
.
sendall
(
self
.
_test_sendall_data
)
finally
:
acceptor
.
join
()
client
.
close
()
server_sock
[
0
][
0
].
close
()
@
greentest
.
ignores_leakcheck
def
test_empty_send
(
self
):
# Issue 719
# Sending empty bytes with the 'send' method raises
# ssl.SSLEOFError in the stdlib. PyPy 4.0 and CPython 2.6
# both just raise the superclass, ssl.SSLError.
expected
=
ssl
.
SSLError
self
.
assertRaises
(
expected
,
self
.
_test_sendall
,
b''
,
client_method
=
'send'
)
# Ignored during leakchecks because the third or fourth iteration of the
# test hangs on CPython 2/posix for some reason, likely due to
# the use of _close_on_teardown keeping something alive longer than intended.
# cf test__makefile_ref
with
self
.
assertRaises
(
ssl
.
SSLError
):
super
(
TestSSL
,
self
).
test_empty_send
()
@
greentest
.
ignores_leakcheck
def
test_sendall_nonblocking
(
self
):
# Override; doesn't work with SSL sockets.
pass
@
greentest
.
ignores_leakcheck
def
test_connect_with_type_flags_ignored
(
self
):
# Override; doesn't work with SSL sockets.
pass
...
...
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