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
3deb1c4e
Commit
3deb1c4e
authored
Apr 10, 2019
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up a ResourceWarning and actually test what we're trying to test on CPython 3.
parent
d069c6ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
19 deletions
+41
-19
src/gevent/tests/known_failures.py
src/gevent/tests/known_failures.py
+1
-0
src/gevent/tests/test__examples.py
src/gevent/tests/test__examples.py
+5
-1
src/gevent/tests/test__greenio.py
src/gevent/tests/test__greenio.py
+35
-18
No files found.
src/gevent/tests/known_failures.py
View file @
3deb1c4e
...
...
@@ -237,6 +237,7 @@ if PYPY:
FAILING_TESTS
+=
[
# A few errors and differences:
# AssertionError: ('255.255.255.255', 'http') != gaierror(-2,) # DNS Python
# AssertionError: ('255.255.255.255', 'http') != gaierror(4, 'ARES_ENOTFOUND: Domain name not found')
# AssertionError: OverflowError('port must be 0-65535.',) != ('readthedocs.org', '65535')
# AssertionError: Lists differ:
...
...
src/gevent/tests/test__examples.py
View file @
3deb1c4e
...
...
@@ -24,6 +24,10 @@ def _find_files_to_ignore():
'psycopg2_pool.py'
,
'geventsendfile.py'
,
]
if
greentest
.
PYPY
and
greentest
.
RUNNING_ON_APPVEYOR
:
# For some reason on Windows with PyPy, this times out,
# when it should be very fast.
result
.
append
(
"processes.py"
)
result
+=
[
x
[
14
:]
for
x
in
glob
.
glob
(
'test__example_*.py'
)]
finally
:
...
...
@@ -34,7 +38,7 @@ def _find_files_to_ignore():
default_time_range
=
(
2
,
4
)
time_ranges
=
{
'concurrent_download.py'
:
(
0
,
30
),
'processes.py'
:
(
0
,
10
)
'processes.py'
:
(
0
,
4
)
}
class
_AbstractTestMixin
(
util
.
ExampleMixin
):
...
...
src/gevent/tests/test__greenio.py
View file @
3deb1c4e
...
...
@@ -22,12 +22,11 @@ import gevent
from
gevent
import
socket
from
gevent.testing
import
TestCase
,
main
,
tcp_listener
from
gevent.testing
import
gc_collect_if_needed
from
gevent.testing
import
skipOnPyPy
from
gevent.testing
import
params
PYPY
=
hasattr
(
sys
,
'pypy_version_info'
)
PY3
=
sys
.
version_info
[
0
]
>=
3
...
...
@@ -91,28 +90,40 @@ class TestGreenIo(TestCase):
did_it_work
(
server
)
server_greenlet
.
kill
()
@
skipOnPyPy
(
"
GC is different
"
)
@
skipOnPyPy
(
"
Takes multiple GCs and issues a warning we can't catch
"
)
def
test_del_closes_socket
(
self
):
import
warnings
def
accept_once
(
listener
):
# delete/overwrite the original conn
# object, only keeping the file object around
# closing the file object should close everything
# XXX: This is not exactly true on Python 3.
# This produces a ResourceWarning.
oconn
=
None
try
:
conn
,
_
=
listener
.
accept
()
if
PY3
:
oconn
=
conn
conn
=
conn
.
makefile
(
mode
=
'wb'
)
conn
.
write
(
b'hello
\
n
'
)
conn
.
close
()
_write_to_closed
(
conn
,
b'a'
)
finally
:
listener
.
close
()
if
oconn
is
not
None
:
oconn
.
close
()
# This is not *exactly* true on Python 3. This produces
# a ResourceWarning, which we silence below. (Previously we actually
# *saved* a reference to the socket object, so we
# weren't testing what we thought we were.)
# It's definitely not true on PyPy, which needs GC to
# reliably close everything; sometimes this is more than
# one collection cycle. And PyPy issues a warning with -X
# track-resources that we cannot catch.
with
warnings
.
catch_warnings
():
warnings
.
simplefilter
(
'ignore'
)
try
:
conn
=
listener
.
accept
()[
0
]
# Note that we overwrite the original variable,
# losing our reference to the socket.
conn
=
conn
.
makefile
(
mode
=
'wb'
)
conn
.
write
(
b'hello
\
n
'
)
conn
.
close
()
_write_to_closed
(
conn
,
b'a'
)
finally
:
listener
.
close
()
del
listener
del
conn
gc_collect_if_needed
()
gc_collect_if_needed
()
server
=
tcp_listener
()
gevent
.
spawn
(
accept_once
,
server
)
...
...
@@ -121,8 +132,14 @@ class TestGreenIo(TestCase):
fd
=
client
.
makefile
()
client
.
close
()
self
.
assertEqual
(
fd
.
read
(),
'hello
\
n
'
)
# If the socket isn't closed when 'accept_once' finished,
# then this will hang and exceed the timeout
self
.
assertEqual
(
fd
.
read
(),
''
)
fd
.
close
()
del
client
del
fd
if
__name__
==
'__main__'
:
main
()
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