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
9cfdda0a
Commit
9cfdda0a
authored
Feb 15, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address some more failing tests. Some of the UDP tests were fighting over ports!
parent
633a7e52
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
123 additions
and
85 deletions
+123
-85
Makefile
Makefile
+2
-2
examples/udp_client.py
examples/udp_client.py
+2
-2
src/greentest/greentest/__init__.py
src/greentest/greentest/__init__.py
+1
-0
src/greentest/greentest/params.py
src/greentest/greentest/params.py
+9
-0
src/greentest/greentest/patched_tests_setup.py
src/greentest/greentest/patched_tests_setup.py
+4
-1
src/greentest/greentest/skipping.py
src/greentest/greentest/skipping.py
+24
-21
src/greentest/greentest/sockets.py
src/greentest/greentest/sockets.py
+3
-2
src/greentest/greentest/testrunner.py
src/greentest/greentest/testrunner.py
+24
-16
src/greentest/known_failures.py
src/greentest/known_failures.py
+5
-3
src/greentest/test___example_servers.py
src/greentest/test___example_servers.py
+1
-0
src/greentest/test__core.py
src/greentest/test__core.py
+6
-3
src/greentest/test__example_portforwarder.py
src/greentest/test__example_portforwarder.py
+4
-4
src/greentest/test__example_udp_client.py
src/greentest/test__example_udp_client.py
+1
-1
src/greentest/test__greenio.py
src/greentest/test__greenio.py
+20
-19
src/greentest/test__greenness.py
src/greentest/test__greenness.py
+17
-11
No files found.
Makefile
View file @
9cfdda0a
...
@@ -90,7 +90,7 @@ allbackendtest:
...
@@ -90,7 +90,7 @@ allbackendtest:
cffibackendtest
:
cffibackendtest
:
@
${PYTHON}
scripts/travis.py fold_start libuv
"Testing libuv backend"
@
${PYTHON}
scripts/travis.py fold_start libuv
"Testing libuv backend"
GEVENT_LOOP
=
libuv
GEVENTTEST_COVERAGE
=
1
make alltest
GEVENT_LOOP
=
libuv make alltest
@
${PYTHON}
scripts/travis.py fold_end libuv
@
${PYTHON}
scripts/travis.py fold_end libuv
@
${PYTHON}
scripts/travis.py fold_start libev
"Testing libev CFFI backend"
@
${PYTHON}
scripts/travis.py fold_start libev
"Testing libev CFFI backend"
GEVENT_LOOP
=
libev-cffi make alltest
GEVENT_LOOP
=
libev-cffi make alltest
...
@@ -193,7 +193,7 @@ test-py37: $(PY37)
...
@@ -193,7 +193,7 @@ test-py37: $(PY37)
LD_LIBRARY_PATH
=
$(BUILD_RUNTIMES)
/versions/python3.7.0b1/openssl/lib
PYTHON
=
python3.7.0b1
PATH
=
$(BUILD_RUNTIMES)
/versions/python3.7.0b1/bin:
$(PATH)
make develop allbackendtest
LD_LIBRARY_PATH
=
$(BUILD_RUNTIMES)
/versions/python3.7.0b1/openssl/lib
PYTHON
=
python3.7.0b1
PATH
=
$(BUILD_RUNTIMES)
/versions/python3.7.0b1/bin:
$(PATH)
make develop allbackendtest
test-pypy
:
$(PYPY)
test-pypy
:
$(PYPY)
PYTHON
=
$(PYPY)
PATH
=
$(BUILD_RUNTIMES)
/versions/pypy5100/bin:
$(PATH)
make develop cffibackendtest
coverage_combine
PYTHON
=
$(PYPY)
PATH
=
$(BUILD_RUNTIMES)
/versions/pypy5100/bin:
$(PATH)
make develop cffibackendtest
test-pypy3
:
$(PYPY3)
test-pypy3
:
$(PYPY3)
PYTHON
=
$(PYPY3)
PATH
=
$(BUILD_RUNTIMES)
/versions/pypy3.5_5101/bin:
$(PATH)
make develop basictest
PYTHON
=
$(PYPY3)
PATH
=
$(BUILD_RUNTIMES)
/versions/pypy3.5_5101/bin:
$(PATH)
make develop basictest
...
...
examples/udp_client.py
View file @
9cfdda0a
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
Usage: python udp_client.py MESSAGE
Usage: python udp_client.py MESSAGE
Make sure you're running a UDP server on port 900
0
(see udp_server.py).
Make sure you're running a UDP server on port 900
1
(see udp_server.py).
There's nothing gevent-specific here.
There's nothing gevent-specific here.
"""
"""
...
@@ -11,7 +11,7 @@ from __future__ import print_function
...
@@ -11,7 +11,7 @@ from __future__ import print_function
import
sys
import
sys
from
gevent
import
socket
from
gevent
import
socket
address
=
(
'localhost'
,
900
0
)
address
=
(
'localhost'
,
900
1
)
message
=
' '
.
join
(
sys
.
argv
[
1
:])
message
=
' '
.
join
(
sys
.
argv
[
1
:])
sock
=
socket
.
socket
(
type
=
socket
.
SOCK_DGRAM
)
sock
=
socket
.
socket
(
type
=
socket
.
SOCK_DGRAM
)
sock
.
connect
(
address
)
sock
.
connect
(
address
)
...
...
src/greentest/greentest/__init__.py
View file @
9cfdda0a
...
@@ -61,6 +61,7 @@ from greentest.skipping import skipOnAppVeyor
...
@@ -61,6 +61,7 @@ from greentest.skipping import skipOnAppVeyor
from
greentest.skipping
import
skipOnCI
from
greentest.skipping
import
skipOnCI
from
greentest.skipping
import
skipOnPyPy3OnCI
from
greentest.skipping
import
skipOnPyPy3OnCI
from
greentest.skipping
import
skipOnPyPy
from
greentest.skipping
import
skipOnPyPy
from
greentest.skipping
import
skipOnPyPyOnCI
from
greentest.skipping
import
skipOnPyPy3
from
greentest.skipping
import
skipOnPyPy3
from
greentest.skipping
import
skipIf
from
greentest.skipping
import
skipIf
from
greentest.skipping
import
skipOnLibuv
from
greentest.skipping
import
skipOnLibuv
...
...
src/greentest/greentest/params.py
View file @
9cfdda0a
...
@@ -26,6 +26,7 @@ from greentest.sysinfo import LIBUV
...
@@ -26,6 +26,7 @@ from greentest.sysinfo import LIBUV
from
greentest.sysinfo
import
OSX
from
greentest.sysinfo
import
OSX
from
greentest.sysinfo
import
RUNNING_ON_TRAVIS
from
greentest.sysinfo
import
RUNNING_ON_TRAVIS
from
greentest.sysinfo
import
RUNNING_ON_APPVEYOR
from
greentest.sysinfo
import
EXPECT_POOR_TIMER_RESOLUTION
from
greentest.sysinfo
import
EXPECT_POOR_TIMER_RESOLUTION
from
greentest.sysinfo
import
RESOLVER_ARES
from
greentest.sysinfo
import
RESOLVER_ARES
...
@@ -62,11 +63,19 @@ if RUNNING_ON_TRAVIS:
...
@@ -62,11 +63,19 @@ if RUNNING_ON_TRAVIS:
# connected to with the same error.
# connected to with the same error.
DEFAULT_BIND_ADDR
=
'127.0.0.1'
DEFAULT_BIND_ADDR
=
'127.0.0.1'
if
RUNNING_ON_APPVEYOR
:
DEFAULT_BIND_ADDR
=
'127.0.0.1'
DEFAULT_LOCAL_HOST_ADDR
=
'127.0.0.1'
if
RESOLVER_ARES
and
OSX
:
if
RESOLVER_ARES
and
OSX
:
# Ares likes to raise "malformed domain name" on '', at least
# Ares likes to raise "malformed domain name" on '', at least
# on OS X
# on OS X
DEFAULT_BIND_ADDR
=
'127.0.0.1'
DEFAULT_BIND_ADDR
=
'127.0.0.1'
DEFAULT_CONNECT
=
DEFAULT_LOCAL_HOST_ADDR
DEFAULT_BIND_ADDR_TUPLE
=
(
DEFAULT_BIND_ADDR
,
0
)
# For in-process sockets
# For in-process sockets
DEFAULT_SOCKET_TIMEOUT
=
0.1
if
not
EXPECT_POOR_TIMER_RESOLUTION
else
2.0
DEFAULT_SOCKET_TIMEOUT
=
0.1
if
not
EXPECT_POOR_TIMER_RESOLUTION
else
2.0
...
...
src/greentest/greentest/patched_tests_setup.py
View file @
9cfdda0a
...
@@ -518,11 +518,14 @@ if WIN:
...
@@ -518,11 +518,14 @@ if WIN:
if
PYPY
:
if
PYPY
:
disabled_tests
+=
[
disabled_tests
+=
[
'test_subprocess.ProcessTestCase.test_failed_child_execute_fd_leak'
,
# Does not exist in the CPython test suite, tests for a specific bug
# Does not exist in the CPython test suite, tests for a specific bug
# in PyPy's forking. Only runs on linux and is specific to the PyPy
# in PyPy's forking. Only runs on linux and is specific to the PyPy
# implementation of subprocess (possibly explains the extra parameter to
# implementation of subprocess (possibly explains the extra parameter to
# _execut_child)
# _execut_child)
'test_subprocess.ProcessTestCase.test_failed_child_execute_fd_leak'
,
# On some platforms, this returns "zlib_compression", but the test is looking for
# "ZLIB"
'test_ssl.ThreadedTests.test_compression'
,
]
]
# Generic Python 3
# Generic Python 3
...
...
src/greentest/greentest/skipping.py
View file @
9cfdda0a
...
@@ -31,10 +31,24 @@ def _do_not_skip(reason):
...
@@ -31,10 +31,24 @@ def _do_not_skip(reason):
return
_identity
return
_identity
skipOnWindows
=
_do_not_skip
skipOnAppVeyor
=
_do_not_skip
skipOnCI
=
_do_not_skip
skipOnPyPy
=
_do_not_skip
skipOnPyPyOnCI
=
_do_not_skip
skipOnPyPy3OnCI
=
_do_not_skip
skipOnPyPy3
=
_do_not_skip
skipOnLibuv
=
_do_not_skip
skipOnLibuvOnCI
=
_do_not_skip
skipOnLibuvOnCIOnPyPy
=
_do_not_skip
skipOnLibuvOnPyPyOnWin
=
_do_not_skip
if
sysinfo
.
WIN
:
if
sysinfo
.
WIN
:
skipOnWindows
=
unittest
.
skip
skipOnWindows
=
unittest
.
skip
else
:
skipOnWindows
=
_do_not_skip
if
sysinfo
.
RUNNING_ON_APPVEYOR
:
if
sysinfo
.
RUNNING_ON_APPVEYOR
:
# See comments scattered around about timeouts and the timer
# See comments scattered around about timeouts and the timer
...
@@ -46,39 +60,28 @@ if sysinfo.RUNNING_ON_APPVEYOR:
...
@@ -46,39 +60,28 @@ if sysinfo.RUNNING_ON_APPVEYOR:
# separately on windows in a more stable environment.
# separately on windows in a more stable environment.
skipOnAppVeyor
=
unittest
.
skip
skipOnAppVeyor
=
unittest
.
skip
else
:
skipOnAppVeyor
=
_do_not_skip
if
sysinfo
.
RUNNING_ON_CI
:
if
sysinfo
.
RUNNING_ON_CI
:
skipOnCI
=
unittest
.
skip
skipOnCI
=
unittest
.
skip
else
:
skipOnCI
=
_do_not_skip
if
sysinfo
.
PYPY3
and
sysinfo
.
RUNNING_ON_CI
:
# Same as above, for PyPy3.3-5.5-alpha and 3.5-5.7.1-beta and 3.5-5.8
skipOnPyPy3OnCI
=
unittest
.
skip
else
:
skipOnPyPy3OnCI
=
_do_not_skip
if
sysinfo
.
PYPY
:
if
sysinfo
.
PYPY
:
skipOnPyPy
=
unittest
.
skip
skipOnPyPy
=
unittest
.
skip
else
:
if
sysinfo
.
RUNNING_ON_CI
:
skipOnPyPy
=
_do_not_
skip
skipOnPyPyOnCI
=
unittest
.
skip
if
sysinfo
.
PYPY3
:
if
sysinfo
.
PYPY3
:
skipOnPyPy3
=
unittest
.
skip
skipOnPyPy3
=
unittest
.
skip
else
:
if
sysinfo
.
RUNNING_ON_CI
:
skipOnPyPy3
=
_do_not_skip
# Same as above, for PyPy3.3-5.5-alpha and 3.5-5.7.1-beta and 3.5-5.8
skipOnPyPy3OnCI
=
unittest
.
skip
skipUnderCoverage
=
unittest
.
skip
if
sysinfo
.
RUN_COVERAGE
else
_do_not_skip
skipUnderCoverage
=
unittest
.
skip
if
sysinfo
.
RUN_COVERAGE
else
_do_not_skip
skipIf
=
unittest
.
skipIf
skipIf
=
unittest
.
skipIf
skipOnLibuv
=
_do_not_skip
skipOnLibuvOnCI
=
_do_not_skip
skipOnLibuvOnCIOnPyPy
=
_do_not_skip
skipOnLibuvOnPyPyOnWin
=
_do_not_skip
if
sysinfo
.
LIBUV
:
if
sysinfo
.
LIBUV
:
skipOnLibuv
=
unittest
.
skip
skipOnLibuv
=
unittest
.
skip
...
...
src/greentest/greentest/sockets.py
View file @
9cfdda0a
...
@@ -19,8 +19,9 @@
...
@@ -19,8 +19,9 @@
# THE SOFTWARE.
# THE SOFTWARE.
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
from
greentest.params
import
DEFAULT_BIND_ADDR_TUPLE
def
bind_and_listen
(
sock
,
address
=
(
''
,
0
)
,
backlog
=
50
,
reuse_addr
=
True
):
def
bind_and_listen
(
sock
,
address
=
DEFAULT_BIND_ADDR_TUPLE
,
backlog
=
50
,
reuse_addr
=
True
):
from
socket
import
SOL_SOCKET
,
SO_REUSEADDR
,
error
from
socket
import
SOL_SOCKET
,
SO_REUSEADDR
,
error
if
reuse_addr
:
if
reuse_addr
:
try
:
try
:
...
@@ -32,7 +33,7 @@ def bind_and_listen(sock, address=('', 0), backlog=50, reuse_addr=True):
...
@@ -32,7 +33,7 @@ def bind_and_listen(sock, address=('', 0), backlog=50, reuse_addr=True):
sock
.
listen
(
backlog
)
sock
.
listen
(
backlog
)
def
tcp_listener
(
address
,
backlog
=
50
,
reuse_addr
=
True
):
def
tcp_listener
(
address
=
DEFAULT_BIND_ADDR_TUPLE
,
backlog
=
50
,
reuse_addr
=
True
):
"""A shortcut to create a TCP socket, bind it and put it into listening state."""
"""A shortcut to create a TCP socket, bind it and put it into listening state."""
from
gevent
import
socket
from
gevent
import
socket
sock
=
socket
.
socket
()
sock
=
socket
.
socket
()
...
...
src/greentest/greentest/testrunner.py
View file @
9cfdda0a
...
@@ -55,7 +55,7 @@ if PYPY:
...
@@ -55,7 +55,7 @@ if PYPY:
]
]
def
run_many
(
tests
,
expected
=
(),
failfast
=
False
,
quiet
=
False
):
def
run_many
(
tests
,
configured_failing_tests
=
(),
failfast
=
False
,
quiet
=
False
):
# pylint:disable=too-many-locals
# pylint:disable=too-many-locals
global
NWORKERS
global
NWORKERS
start
=
time
.
time
()
start
=
time
.
time
()
...
@@ -127,7 +127,8 @@ def run_many(tests, expected=(), failfast=False, quiet=False):
...
@@ -127,7 +127,8 @@ def run_many(tests, expected=(), failfast=False, quiet=False):
reap_all
()
reap_all
()
except
KeyboardInterrupt
:
except
KeyboardInterrupt
:
pool
.
terminate
()
pool
.
terminate
()
report
(
total
,
failed
,
passed
,
exit
=
False
,
took
=
time
.
time
()
-
start
,
expected
=
expected
)
report
(
total
,
failed
,
passed
,
exit
=
False
,
took
=
time
.
time
()
-
start
,
configured_failing_tests
=
configured_failing_tests
)
log
(
'(partial results)
\
n
'
)
log
(
'(partial results)
\
n
'
)
raise
raise
except
:
except
:
...
@@ -136,17 +137,18 @@ def run_many(tests, expected=(), failfast=False, quiet=False):
...
@@ -136,17 +137,18 @@ def run_many(tests, expected=(), failfast=False, quiet=False):
raise
raise
reap_all
()
reap_all
()
report
(
total
,
failed
,
passed
,
took
=
time
.
time
()
-
start
,
expected
=
expected
)
report
(
total
,
failed
,
passed
,
took
=
time
.
time
()
-
start
,
configured_failing_tests
=
configured_failing_tests
)
def
discover
(
tests
=
None
,
ignore
=
(),
coverage
=
False
):
def
discover
(
tests
=
None
,
ignore_files
=
None
,
if
isinstance
(
ignore
,
six
.
string_types
):
ignored
=
(),
coverage
=
False
):
ignore_files
=
ignore
.
split
(
','
)
ignore
=
set
(
ignored
or
())
ignore
=
set
()
if
ignore_files
:
ignore_files
=
ignore_files
.
split
(
','
)
for
f
in
ignore_files
:
for
f
in
ignore_files
:
ignore
.
update
(
set
(
load_list_from_file
(
f
)))
ignore
.
update
(
set
(
load_list_from_file
(
f
)))
ignore
=
set
(
ignore
or
())
if
coverage
:
if
coverage
:
ignore
.
update
(
IGNORE_COVERAGE
)
ignore
.
update
(
IGNORE_COVERAGE
)
...
@@ -200,10 +202,10 @@ def load_list_from_file(filename):
...
@@ -200,10 +202,10 @@ def load_list_from_file(filename):
return
result
return
result
def
matches
(
expected
,
command
,
include_flaky
=
True
):
def
matches
(
possibilities
,
command
,
include_flaky
=
True
):
if
isinstance
(
command
,
list
):
if
isinstance
(
command
,
list
):
command
=
' '
.
join
(
command
)
command
=
' '
.
join
(
command
)
for
line
in
expected
:
for
line
in
possibilities
:
if
not
include_flaky
and
line
.
startswith
(
'FLAKY '
):
if
not
include_flaky
and
line
.
startswith
(
'FLAKY '
):
continue
continue
if
command
.
endswith
(
' '
+
line
.
replace
(
'FLAKY '
,
''
)):
if
command
.
endswith
(
' '
+
line
.
replace
(
'FLAKY '
,
''
)):
...
@@ -220,7 +222,8 @@ def format_seconds(seconds):
...
@@ -220,7 +222,8 @@ def format_seconds(seconds):
return
seconds
return
seconds
def
report
(
total
,
failed
,
passed
,
exit
=
True
,
took
=
None
,
expected
=
None
):
def
report
(
total
,
failed
,
passed
,
exit
=
True
,
took
=
None
,
configured_failing_tests
=
()):
# pylint:disable=redefined-builtin,too-many-branches
# pylint:disable=redefined-builtin,too-many-branches
runtimelog
=
util
.
runtimelog
runtimelog
=
util
.
runtimelog
if
runtimelog
:
if
runtimelog
:
...
@@ -240,7 +243,7 @@ def report(total, failed, passed, exit=True, took=None, expected=None):
...
@@ -240,7 +243,7 @@ def report(total, failed, passed, exit=True, took=None, expected=None):
passed_unexpected
=
[]
passed_unexpected
=
[]
for
name
in
passed
:
for
name
in
passed
:
if
matches
(
expected
,
name
,
include_flaky
=
False
):
if
matches
(
configured_failing_tests
,
name
,
include_flaky
=
False
):
passed_unexpected
.
append
(
name
)
passed_unexpected
.
append
(
name
)
if
passed_unexpected
:
if
passed_unexpected
:
...
@@ -249,9 +252,9 @@ def report(total, failed, passed, exit=True, took=None, expected=None):
...
@@ -249,9 +252,9 @@ def report(total, failed, passed, exit=True, took=None, expected=None):
if
failed
:
if
failed
:
log
(
'
\
n
%s/%s tests failed%s'
,
len
(
failed
),
total
,
took
)
log
(
'
\
n
%s/%s tests failed%s'
,
len
(
failed
),
total
,
took
)
expected
=
set
(
expected
or
[])
for
name
in
failed
:
for
name
in
failed
:
if
matches
(
expected
,
name
,
include_flaky
=
True
):
if
matches
(
configured_failing_tests
,
name
,
include_flaky
=
True
):
failed_expected
.
append
(
name
)
failed_expected
.
append
(
name
)
else
:
else
:
failed_unexpected
.
append
(
name
)
failed_unexpected
.
append
(
name
)
...
@@ -293,6 +296,7 @@ def main():
...
@@ -293,6 +296,7 @@ def main():
parser
.
add_argument
(
'tests'
,
nargs
=
'*'
)
parser
.
add_argument
(
'tests'
,
nargs
=
'*'
)
options
=
parser
.
parse_args
()
options
=
parser
.
parse_args
()
FAILING_TESTS
=
[]
FAILING_TESTS
=
[]
IGNORED_TESTS
=
[]
coverage
=
False
coverage
=
False
if
options
.
coverage
or
os
.
environ
.
get
(
"GEVENTTEST_COVERAGE"
):
if
options
.
coverage
or
os
.
environ
.
get
(
"GEVENTTEST_COVERAGE"
):
coverage
=
True
coverage
=
True
...
@@ -312,6 +316,7 @@ def main():
...
@@ -312,6 +316,7 @@ def main():
config_data
=
f
.
read
()
config_data
=
f
.
read
()
six
.
exec_
(
config_data
,
config
)
six
.
exec_
(
config_data
,
config
)
FAILING_TESTS
=
config
[
'FAILING_TESTS'
]
FAILING_TESTS
=
config
[
'FAILING_TESTS'
]
IGNORED_TESTS
=
config
[
'IGNORED_TESTS'
]
if
'PYTHONWARNINGS'
not
in
os
.
environ
and
not
sys
.
warnoptions
:
if
'PYTHONWARNINGS'
not
in
os
.
environ
and
not
sys
.
warnoptions
:
# Enable default warnings such as ResourceWarning.
# Enable default warnings such as ResourceWarning.
...
@@ -330,13 +335,16 @@ def main():
...
@@ -330,13 +335,16 @@ def main():
if
'GEVENT_DEBUG'
not
in
os
.
environ
:
if
'GEVENT_DEBUG'
not
in
os
.
environ
:
os
.
environ
[
'GEVENT_DEBUG'
]
=
'debug'
os
.
environ
[
'GEVENT_DEBUG'
]
=
'debug'
tests
=
discover
(
options
.
tests
,
options
.
ignore
,
coverage
)
tests
=
discover
(
options
.
tests
,
ignore_files
=
options
.
ignore
,
ignored
=
IGNORED_TESTS
,
coverage
=
coverage
)
if
options
.
discover
:
if
options
.
discover
:
for
cmd
,
options
in
tests
:
for
cmd
,
options
in
tests
:
print
(
util
.
getname
(
cmd
,
env
=
options
.
get
(
'env'
),
setenv
=
options
.
get
(
'setenv'
)))
print
(
util
.
getname
(
cmd
,
env
=
options
.
get
(
'env'
),
setenv
=
options
.
get
(
'setenv'
)))
print
(
'%s tests found.'
%
len
(
tests
))
print
(
'%s tests found.'
%
len
(
tests
))
else
:
else
:
run_many
(
tests
,
expected
=
FAILING_TESTS
,
failfast
=
options
.
failfast
,
quiet
=
options
.
quiet
)
run_many
(
tests
,
configured_failing_tests
=
FAILING_TESTS
,
failfast
=
options
.
failfast
,
quiet
=
options
.
quiet
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
src/greentest/known_failures.py
View file @
9cfdda0a
...
@@ -18,6 +18,7 @@ from greentest.sysinfo import PY35
...
@@ -18,6 +18,7 @@ from greentest.sysinfo import PY35
from
greentest.sysinfo
import
LIBUV
from
greentest.sysinfo
import
LIBUV
IGNORED_TESTS
=
[]
FAILING_TESTS
=
[
FAILING_TESTS
=
[
...
@@ -70,14 +71,15 @@ if sys.platform == 'win32':
...
@@ -70,14 +71,15 @@ if sys.platform == 'win32':
]
]
if
PYPY
and
LIBUV
:
if
PYPY
and
LIBUV
:
FAILING
_TESTS
+=
[
IGNORED
_TESTS
+=
[
# This one s
ometimes s
eems to just stop right after
# This one seems to just stop right after
# patching is done. It passes on a local win 10 vm, and the main
# patching is done. It passes on a local win 10 vm, and the main
# test_threading_2.py does as well.
# test_threading_2.py does as well.
# Based on the printouts we added, it appears to not even
# Based on the printouts we added, it appears to not even
# finish importing:
# finish importing:
# https://ci.appveyor.com/project/denik/gevent/build/1.0.1277/job/tpvhesij5gldjxqw#L1190
# https://ci.appveyor.com/project/denik/gevent/build/1.0.1277/job/tpvhesij5gldjxqw#L1190
'FLAKY test_threading.py'
,
# Ignored because it takes two minutes to time out.
'test_threading.py'
,
]
]
if
PY3
:
if
PY3
:
...
...
src/greentest/test___example_servers.py
View file @
9cfdda0a
...
@@ -14,6 +14,7 @@ from greentest import DEFAULT_XPC_SOCKET_TIMEOUT
...
@@ -14,6 +14,7 @@ from greentest import DEFAULT_XPC_SOCKET_TIMEOUT
from
greentest
import
util
from
greentest
import
util
from
greentest
import
params
from
greentest
import
params
@
greentest
.
skipOnLibuvOnCIOnPyPy
(
"Timing issues sometimes lead to a connection refused"
)
class
Test_wsgiserver
(
util
.
TestServer
):
class
Test_wsgiserver
(
util
.
TestServer
):
server
=
'wsgiserver.py'
server
=
'wsgiserver.py'
URL
=
'http://%s:8088'
%
(
params
.
DEFAULT_LOCAL_HOST_ADDR
,)
URL
=
'http://%s:8088'
%
(
params
.
DEFAULT_LOCAL_HOST_ADDR
,)
...
...
src/greentest/test__core.py
View file @
9cfdda0a
# pylint:disable=no-member
# pylint:disable=no-member
import
sys
import
sys
import
unittest
import
unittest
from
greentest
import
main
,
skipOnLibuv
import
greentest
from
gevent
import
core
from
gevent
import
core
...
@@ -66,6 +67,8 @@ class TestWatchersDefault(TestWatchers):
...
@@ -66,6 +67,8 @@ class TestWatchersDefault(TestWatchers):
def
makeOne
(
self
):
def
makeOne
(
self
):
return
core
.
loop
(
default
=
True
)
return
core
.
loop
(
default
=
True
)
@
greentest
.
skipOnLibuvOnPyPyOnWin
(
"This crashes with PyPy 5.10.0, only on Windows. "
"See https://ci.appveyor.com/project/denik/gevent/build/1.0.1380/job/lrlvid6mkjtyrhn5#L1103"
)
class
TestWatchersDefaultDestroyed
(
TestWatchers
):
class
TestWatchersDefaultDestroyed
(
TestWatchers
):
def
makeOne
(
self
):
def
makeOne
(
self
):
...
@@ -74,7 +77,7 @@ class TestWatchersDefaultDestroyed(TestWatchers):
...
@@ -74,7 +77,7 @@ class TestWatchersDefaultDestroyed(TestWatchers):
del
l
del
l
return
core
.
loop
(
default
=
True
)
return
core
.
loop
(
default
=
True
)
@
skipOnLibuv
(
"Tests for libev-only functions"
)
@
greentest
.
skipOnLibuv
(
"Tests for libev-only functions"
)
class
TestLibev
(
unittest
.
TestCase
):
class
TestLibev
(
unittest
.
TestCase
):
def
test_flags_conversion
(
self
):
def
test_flags_conversion
(
self
):
...
@@ -98,4 +101,4 @@ class TestEvents(unittest.TestCase):
...
@@ -98,4 +101,4 @@ class TestEvents(unittest.TestCase):
self
.
assertEqual
(
repr
(
core
.
EVENTS
),
'gevent.core.EVENTS'
)
self
.
assertEqual
(
repr
(
core
.
EVENTS
),
'gevent.core.EVENTS'
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
greentest
.
main
()
src/greentest/test__example_portforwarder.py
View file @
9cfdda0a
from
__future__
import
print_function
from
__future__
import
print_function
,
absolute_import
from
gevent
import
monkey
;
monkey
.
patch_all
(
subprocess
=
True
)
from
gevent
import
monkey
;
monkey
.
patch_all
(
subprocess
=
True
)
import
signal
import
signal
import
sys
import
sys
...
@@ -8,9 +8,10 @@ from time import sleep
...
@@ -8,9 +8,10 @@ from time import sleep
import
gevent
import
gevent
from
gevent.server
import
StreamServer
from
gevent.server
import
StreamServer
import
greentest
from
greentest
import
util
from
greentest
import
util
@
greentest
.
skipOnLibuvOnCIOnPyPy
(
"Timing issues sometimes lead to connection refused"
)
class
Test
(
util
.
TestServer
):
class
Test
(
util
.
TestServer
):
server
=
'portforwarder.py'
server
=
'portforwarder.py'
args
=
[
'127.0.0.1:10011'
,
'127.0.0.1:10012'
]
args
=
[
'127.0.0.1:10011'
,
'127.0.0.1:10012'
]
...
@@ -62,5 +63,4 @@ class Test(util.TestServer):
...
@@ -62,5 +63,4 @@ class Test(util.TestServer):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
from
greentest
import
main
greentest
.
main
()
main
()
src/greentest/test__example_udp_client.py
View file @
9cfdda0a
...
@@ -14,7 +14,7 @@ class Test_udp_client(TestCase):
...
@@ -14,7 +14,7 @@ class Test_udp_client(TestCase):
log
.
append
(
message
)
log
.
append
(
message
)
server
.
sendto
(
b'reply-from-server'
,
address
)
server
.
sendto
(
b'reply-from-server'
,
address
)
server
=
DatagramServer
(
'127.0.0.1:900
0
'
,
handle
)
server
=
DatagramServer
(
'127.0.0.1:900
1
'
,
handle
)
server
.
start
()
server
.
start
()
try
:
try
:
run
([
sys
.
executable
,
'-W'
,
'ignore'
,
'-u'
,
'udp_client.py'
,
'Test_udp_client'
],
run
([
sys
.
executable
,
'-W'
,
'ignore'
,
'-u'
,
'udp_client.py'
,
'Test_udp_client'
],
...
...
src/greentest/test__greenio.py
View file @
9cfdda0a
...
@@ -16,12 +16,15 @@
...
@@ -16,12 +16,15 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# THE SOFTWARE.
import
sys
from
greentest
import
TestCase
,
main
,
tcp_listener
from
greentest
import
skipOnPyPy
import
gevent
import
gevent
from
gevent
import
socket
from
gevent
import
socket
import
sys
from
greentest
import
TestCase
,
main
,
tcp_listener
from
greentest
import
skipOnPyPy
from
greentest
import
params
PYPY
=
hasattr
(
sys
,
'pypy_version_info'
)
PYPY
=
hasattr
(
sys
,
'pypy_version_info'
)
...
@@ -45,7 +48,7 @@ class TestGreenIo(TestCase):
...
@@ -45,7 +48,7 @@ class TestGreenIo(TestCase):
# verify that the makefile and the socket are truly independent
# verify that the makefile and the socket are truly independent
# by closing the socket prior to using the made file
# by closing the socket prior to using the made file
try
:
try
:
conn
,
addr
=
listener
.
accept
()
conn
,
_
=
listener
.
accept
()
fd
=
conn
.
makefile
(
mode
=
'wb'
)
fd
=
conn
.
makefile
(
mode
=
'wb'
)
conn
.
close
()
conn
.
close
()
fd
.
write
(
b'hello
\
n
'
)
fd
.
write
(
b'hello
\
n
'
)
...
@@ -59,7 +62,7 @@ class TestGreenIo(TestCase):
...
@@ -59,7 +62,7 @@ class TestGreenIo(TestCase):
# verify that the makefile and the socket are truly independent
# verify that the makefile and the socket are truly independent
# by closing the made file and then sending a character
# by closing the made file and then sending a character
try
:
try
:
conn
,
addr
=
listener
.
accept
()
conn
,
_
=
listener
.
accept
()
fd
=
conn
.
makefile
(
mode
=
'wb'
)
fd
=
conn
.
makefile
(
mode
=
'wb'
)
fd
.
write
(
b'hello'
)
fd
.
write
(
b'hello'
)
fd
.
close
()
fd
.
close
()
...
@@ -71,27 +74,25 @@ class TestGreenIo(TestCase):
...
@@ -71,27 +74,25 @@ class TestGreenIo(TestCase):
listener
.
close
()
listener
.
close
()
def
did_it_work
(
server
):
def
did_it_work
(
server
):
client
=
socket
.
create_connection
((
'127.0.0.1'
,
server
.
getsockname
()[
1
]))
client
=
socket
.
create_connection
((
params
.
DEFAULT_CONNECT
,
server
.
getsockname
()[
1
]))
fd
=
client
.
makefile
(
mode
=
'rb'
)
fd
=
client
.
makefile
(
mode
=
'rb'
)
client
.
close
()
client
.
close
()
assert
fd
.
readline
()
==
b'hello
\
n
'
self
.
assertEqual
(
fd
.
readline
(),
b'hello
\
n
'
)
assert
fd
.
read
()
==
b''
self
.
assertFalse
(
fd
.
read
())
fd
.
close
()
fd
.
close
()
server
=
tcp_listener
(
(
'0.0.0.0'
,
0
)
)
server
=
tcp_listener
()
server_greenlet
=
gevent
.
spawn
(
accept_close_early
,
server
)
server_greenlet
=
gevent
.
spawn
(
accept_close_early
,
server
)
did_it_work
(
server
)
did_it_work
(
server
)
server_greenlet
.
kill
()
server_greenlet
.
kill
()
server
=
tcp_listener
(
(
'0.0.0.0'
,
0
)
)
server
=
tcp_listener
()
server_greenlet
=
gevent
.
spawn
(
accept_close_late
,
server
)
server_greenlet
=
gevent
.
spawn
(
accept_close_late
,
server
)
did_it_work
(
server
)
did_it_work
(
server
)
server_greenlet
.
kill
()
server_greenlet
.
kill
()
@
skipOnPyPy
(
"GC is different"
)
@
skipOnPyPy
(
"GC is different"
)
def
test_del_closes_socket
(
self
):
def
test_del_closes_socket
(
self
):
timer
=
gevent
.
Timeout
.
start_new
(
0.5
)
def
accept_once
(
listener
):
def
accept_once
(
listener
):
# delete/overwrite the original conn
# delete/overwrite the original conn
# object, only keeping the file object around
# object, only keeping the file object around
...
@@ -113,15 +114,15 @@ class TestGreenIo(TestCase):
...
@@ -113,15 +114,15 @@ class TestGreenIo(TestCase):
if
oconn
is
not
None
:
if
oconn
is
not
None
:
oconn
.
close
()
oconn
.
close
()
server
=
tcp_listener
(
(
'0.0.0.0'
,
0
)
)
server
=
tcp_listener
()
gevent
.
spawn
(
accept_once
,
server
)
gevent
.
spawn
(
accept_once
,
server
)
client
=
socket
.
create_connection
((
'127.0.0.1'
,
server
.
getsockname
()[
1
]))
client
=
socket
.
create_connection
((
params
.
DEFAULT_CONNECT
,
server
.
getsockname
()[
1
]))
with
gevent
.
Timeout
.
start_new
(
0.5
):
fd
=
client
.
makefile
()
fd
=
client
.
makefile
()
client
.
close
()
client
.
close
()
assert
fd
.
read
()
==
'hello
\
n
'
self
.
assertEqual
(
fd
.
read
(),
'hello
\
n
'
)
assert
fd
.
read
()
==
''
self
.
assertEqual
(
fd
.
read
(),
''
)
timer
.
close
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
src/greentest/test__greenness.py
View file @
9cfdda0a
...
@@ -23,9 +23,11 @@
...
@@ -23,9 +23,11 @@
To do that spawn a green server and then access it using a green socket.
To do that spawn a green server and then access it using a green socket.
If either operation blocked the whole script would block and timeout.
If either operation blocked the whole script would block and timeout.
"""
"""
import
greentest
from
gevent
import
monkey
from
gevent
import
monkey
monkey
.
patch_all
()
monkey
.
patch_all
()
import
greentest
try
:
try
:
import
urllib2
import
urllib2
except
ImportError
:
except
ImportError
:
...
@@ -34,33 +36,37 @@ try:
...
@@ -34,33 +36,37 @@ try:
import
BaseHTTPServer
import
BaseHTTPServer
except
ImportError
:
except
ImportError
:
from
http
import
server
as
BaseHTTPServer
from
http
import
server
as
BaseHTTPServer
import
gevent
import
gevent
from
greentest
import
params
class
TestGreenness
(
greentest
.
TestCase
):
class
TestGreenness
(
greentest
.
TestCase
):
check_totalrefcount
=
False
check_totalrefcount
=
False
def
setUp
(
self
):
server_address
=
params
.
DEFAULT_BIND_ADDR_TUPLE
BaseHTTPServer
.
BaseHTTPRequestHandler
.
protocol_version
=
"HTTP/1.0"
self
.
httpd
=
BaseHTTPServer
.
HTTPServer
(
server_address
,
BaseHTTPServer
.
BaseHTTPRequestHandler
)
self
.
httpd
.
request_count
=
0
def
tearDown
(
self
):
self
.
httpd
.
server_close
()
self
.
httpd
=
None
def
serve
(
self
):
def
serve
(
self
):
self
.
httpd
.
handle_request
()
self
.
httpd
.
handle_request
()
self
.
httpd
.
request_count
+=
1
self
.
httpd
.
request_count
+=
1
def
test_urllib2
(
self
):
def
test_urllib2
(
self
):
server_address
=
(
''
,
0
)
BaseHTTPServer
.
BaseHTTPRequestHandler
.
protocol_version
=
"HTTP/1.0"
self
.
httpd
=
BaseHTTPServer
.
HTTPServer
(
server_address
,
BaseHTTPServer
.
BaseHTTPRequestHandler
)
self
.
httpd
.
request_count
=
0
server
=
gevent
.
spawn
(
self
.
serve
)
server
=
gevent
.
spawn
(
self
.
serve
)
port
=
self
.
httpd
.
socket
.
getsockname
()[
1
]
port
=
self
.
httpd
.
socket
.
getsockname
()[
1
]
try
:
with
self
.
assertRaises
(
urllib2
.
HTTPError
)
as
exc
:
urllib2
.
urlopen
(
'http://127.0.0.1:%s'
%
port
)
urllib2
.
urlopen
(
'http://127.0.0.1:%s'
%
port
)
assert
False
,
'should not get there'
self
.
assertEqual
(
exc
.
exception
.
code
,
501
)
except
urllib2
.
HTTPError
as
ex
:
assert
ex
.
code
==
501
,
repr
(
ex
)
server
.
get
(
0.01
)
server
.
get
(
0.01
)
self
.
assertEqual
(
self
.
httpd
.
request_count
,
1
)
self
.
assertEqual
(
self
.
httpd
.
request_count
,
1
)
self
.
httpd
.
server_close
()
self
.
httpd
=
None
if
__name__
==
'__main__'
:
if
__name__
==
'__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