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
9535660a
Commit
9535660a
authored
Apr 20, 2020
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rework the testrunner to group tests.
This almost cuts the test time in half on my machine.
parent
3f41248c
Changes
27
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
367 additions
and
170 deletions
+367
-170
src/gevent/testing/hub.py
src/gevent/testing/hub.py
+5
-0
src/gevent/testing/patched_tests_setup.py
src/gevent/testing/patched_tests_setup.py
+1
-1
src/gevent/testing/testrunner.py
src/gevent/testing/testrunner.py
+250
-93
src/gevent/tests/test__ares_timeout.py
src/gevent/tests/test__ares_timeout.py
+2
-1
src/gevent/tests/test__backdoor.py
src/gevent/tests/test__backdoor.py
+1
-1
src/gevent/tests/test__core_async.py
src/gevent/tests/test__core_async.py
+16
-9
src/gevent/tests/test__core_callback.py
src/gevent/tests/test__core_callback.py
+20
-19
src/gevent/tests/test__destroy.py
src/gevent/tests/test__destroy.py
+1
-1
src/gevent/tests/test__example_portforwarder.py
src/gevent/tests/test__example_portforwarder.py
+1
-1
src/gevent/tests/test__example_udp_client.py
src/gevent/tests/test__example_udp_client.py
+1
-1
src/gevent/tests/test__greenio.py
src/gevent/tests/test__greenio.py
+3
-2
src/gevent/tests/test__joinall.py
src/gevent/tests/test__joinall.py
+15
-5
src/gevent/tests/test__loop_callback.py
src/gevent/tests/test__loop_callback.py
+14
-9
src/gevent/tests/test__memleak.py
src/gevent/tests/test__memleak.py
+2
-2
src/gevent/tests/test__monkey.py
src/gevent/tests/test__monkey.py
+1
-2
src/gevent/tests/test__pywsgi.py
src/gevent/tests/test__pywsgi.py
+1
-1
src/gevent/tests/test__queue.py
src/gevent/tests/test__queue.py
+2
-2
src/gevent/tests/test__real_greenlet.py
src/gevent/tests/test__real_greenlet.py
+16
-11
src/gevent/tests/test__server.py
src/gevent/tests/test__server.py
+4
-1
src/gevent/tests/test__socket.py
src/gevent/tests/test__socket.py
+4
-2
src/gevent/tests/test__threading.py
src/gevent/tests/test__threading.py
+1
-1
src/gevent/tests/test__threading_before_monkey.py
src/gevent/tests/test__threading_before_monkey.py
+1
-1
src/gevent/tests/test__threading_holding_lock_while_monkey.py
...gevent/tests/test__threading_holding_lock_while_monkey.py
+1
-1
src/gevent/tests/test__threading_monkey_in_thread.py
src/gevent/tests/test__threading_monkey_in_thread.py
+1
-1
src/gevent/tests/test__threading_native_before_monkey.py
src/gevent/tests/test__threading_native_before_monkey.py
+1
-1
src/gevent/tests/test__threading_vs_settrace.py
src/gevent/tests/test__threading_vs_settrace.py
+1
-1
src/gevent/tests/test__util.py
src/gevent/tests/test__util.py
+1
-0
No files found.
src/gevent/testing/hub.py
View file @
9535660a
...
...
@@ -25,6 +25,8 @@ from gevent.hub import Hub
from
.exception
import
ExpectedException
class
QuietHub
(
Hub
):
_resolver
=
None
_threadpool
=
None
EXPECTED_TEST_ERROR
=
(
ExpectedException
,)
...
...
@@ -42,3 +44,6 @@ class QuietHub(Hub):
# see handle_error
return
return
Hub
.
print_exception
(
self
,
context
,
t
,
v
,
tb
)
def
destroy
(
self
,
destroy_loop
=
None
):
raise
AssertionError
(
"Do not destroy the hub in a unittest"
)
src/gevent/testing/patched_tests_setup.py
View file @
9535660a
...
...
@@ -1247,7 +1247,7 @@ disabled_tests += [
'test_ssl.BasicSocketTests.test_openssl_version'
]
if
TRAVIS
and
OSX
:
if
OSX
:
disabled_tests
+=
[
# This sometimes produces OSError: Errno 40: Message too long
...
...
src/gevent/testing/testrunner.py
View file @
9535660a
This diff is collapsed.
Click to expand it.
src/gevent/tests/test__ares_timeout.py
View file @
9535660a
...
...
@@ -29,7 +29,8 @@ class TestTimeout(greentest.TestCase):
while
True
:
listener
.
recvfrom
(
10000
)
gevent
.
spawn
(
reader
)
greader
=
gevent
.
spawn
(
reader
)
self
.
_close_on_teardown
(
greader
.
kill
)
r
=
Resolver
(
servers
=
[
address
[
0
]],
timeout
=
0.001
,
tries
=
1
,
udp_port
=
address
[
-
1
])
...
...
src/gevent/tests/test__backdoor.py
View file @
9535660a
...
...
@@ -158,4 +158,4 @@ class Test(greentest.TestCase):
if
__name__
==
'__main__'
:
greentest
.
main
()
greentest
.
main
()
# pragma: testrunner-no-combine
src/gevent/tests/test__core_async.py
View file @
9535660a
...
...
@@ -7,18 +7,25 @@ try:
except
ImportError
:
import
_thread
as
thread
from
gevent
import
testing
as
greentest
hub
=
gevent
.
get_hub
()
watcher
=
hub
.
loop
.
async_
()
class
Test
(
greentest
.
TestCase
):
def
test
(
self
):
hub
=
gevent
.
get_hub
()
watcher
=
hub
.
loop
.
async_
()
# BWC for <3.7: This should still be an attribute
assert
hasattr
(
hub
.
loop
,
'async'
)
# BWC for <3.7: This should still be an attribute
assert
hasattr
(
hub
.
loop
,
'async'
)
gevent
.
spawn_later
(
0.1
,
thread
.
start_new_thread
,
watcher
.
send
,
())
gevent
.
spawn_later
(
0.1
,
thread
.
start_new_thread
,
watcher
.
send
,
())
start
=
time
.
time
()
start
=
time
.
time
()
with
gevent
.
Timeout
(
1.0
):
# Large timeout for appveyor
hub
.
wait
(
watcher
)
with
gevent
.
Timeout
(
1.0
):
# Large timeout for appveyor
hub
.
wait
(
watcher
)
print
(
'Watcher %r reacted after %.6f seconds'
%
(
watcher
,
time
.
time
()
-
start
-
0.1
))
print
(
'Watcher %r reacted after %.6f seconds'
%
(
watcher
,
time
.
time
()
-
start
-
0.1
))
if
__name__
==
'__main__'
:
greentest
.
main
()
src/gevent/tests/test__core_callback.py
View file @
9535660a
import
gevent
from
gevent.hub
import
get_hub
called
=
[]
from
gevent
import
testing
as
greentest
class
Test
(
greentest
.
TestCase
):
def
f
():
called
.
append
(
1
)
def
test
(
self
):
loop
=
get_hub
().
loop
called
=
[]
def
f
():
called
.
append
(
1
)
def
main
():
loop
=
get_hub
().
loop
x
=
loop
.
run_callback
(
f
)
x
=
loop
.
run_callback
(
f
)
assert
x
,
x
gevent
.
sleep
(
0
)
assert
called
==
[
1
],
called
assert
not
x
,
(
x
,
bool
(
x
))
assert
x
,
x
gevent
.
sleep
(
0
)
assert
called
==
[
1
],
called
assert
not
x
,
(
x
,
bool
(
x
))
x
=
loop
.
run_callback
(
f
)
assert
x
,
x
x
.
stop
()
assert
not
x
,
x
gevent
.
sleep
(
0
)
assert
called
==
[
1
],
called
assert
not
x
,
x
x
=
loop
.
run_callback
(
f
)
assert
x
,
x
x
.
stop
()
assert
not
x
,
x
gevent
.
sleep
(
0
)
assert
called
==
[
1
],
called
assert
not
x
,
x
if
__name__
==
'__main__'
:
called
[:]
=
[]
main
()
greentest
.
main
()
src/gevent/tests/test__destroy.py
View file @
9535660a
...
...
@@ -48,4 +48,4 @@ class TestDestroyHub(unittest.TestCase):
hub
.
destroy
()
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
# pragma: testrunner-no-combine
src/gevent/tests/test__example_portforwarder.py
View file @
9535660a
from
__future__
import
print_function
,
absolute_import
from
gevent
import
monkey
;
monkey
.
patch_all
(
subprocess
=
True
)
from
gevent
import
monkey
;
monkey
.
patch_all
()
import
signal
import
socket
...
...
src/gevent/tests/test__example_udp_client.py
View file @
9535660a
from
gevent
import
monkey
monkey
.
patch_all
(
subprocess
=
True
)
monkey
.
patch_all
()
from
gevent.server
import
DatagramServer
...
...
src/gevent/tests/test__greenio.py
View file @
9535660a
...
...
@@ -21,7 +21,8 @@ import sys
import
gevent
from
gevent
import
socket
from
gevent.testing
import
TestCase
,
main
,
tcp_listener
from
gevent
import
testing
as
greentest
from
gevent.testing
import
TestCase
,
tcp_listener
from
gevent.testing
import
gc_collect_if_needed
from
gevent.testing
import
skipOnPyPy
from
gevent.testing
import
params
...
...
@@ -142,4 +143,4 @@ class TestGreenIo(TestCase):
if
__name__
==
'__main__'
:
main
()
greentest
.
main
()
src/gevent/tests/test__joinall.py
View file @
9535660a
import
gevent
from
gevent
import
testing
as
greentest
def
func
():
pass
class
Test
(
greentest
.
TestCase
):
a
=
gevent
.
spawn
(
func
)
b
=
gevent
.
spawn
(
func
)
gevent
.
joinall
([
a
,
b
,
a
])
def
test
(
self
):
def
func
():
pass
a
=
gevent
.
spawn
(
func
)
b
=
gevent
.
spawn
(
func
)
gevent
.
joinall
([
a
,
b
,
a
])
if
__name__
==
'__main__'
:
greentest
.
main
()
src/gevent/tests/test__loop_callback.py
View file @
9535660a
from
gevent.core
import
loop
from
gevent
import
get_hub
from
gevent
import
testing
as
greentest
count
=
0
class
Test
(
greentest
.
TestCase
):
def
test
(
self
):
count
=
[
0
]
def
incr
():
count
[
0
]
+=
1
def
incr
():
global
count
count
+=
1
loop
=
get_hub
().
loop
loop
.
run_callback
(
incr
)
loop
.
run
()
self
.
assertEqual
(
count
,
[
1
])
loop
=
loop
()
loop
.
run_callback
(
incr
)
loop
.
run
()
assert
count
==
1
,
count
if
__name__
==
'__main__'
:
greentest
.
main
()
src/gevent/tests/test__memleak.py
View file @
9535660a
import
sys
import
unittest
from
gevent.testing
import
TestCase
,
main
from
gevent.testing
import
TestCase
import
gevent
from
gevent.timeout
import
Timeout
...
...
@@ -53,4 +53,4 @@ class TestQueue(TestCase): # pragma: no cover
if
__name__
==
'__main__'
:
main
()
unittest
.
main
()
src/gevent/tests/test__monkey.py
View file @
9535660a
from
subprocess
import
Popen
from
gevent
import
monkey
monkey
.
patch_all
()
...
...
@@ -79,6 +77,7 @@ class TestMonkey(SubscriberCleanupMixin, unittest.TestCase):
self
.
assertTrue
(
monkey
.
is_object_patched
(
modname
,
objname
))
def
test_patch_subprocess_twice
(
self
):
Popen
=
monkey
.
get_original
(
'subprocess'
,
'Popen'
)
self
.
assertNotIn
(
'gevent'
,
repr
(
Popen
))
self
.
assertIs
(
Popen
,
monkey
.
get_original
(
'subprocess'
,
'Popen'
))
monkey
.
patch_subprocess
()
...
...
src/gevent/tests/test__pywsgi.py
View file @
9535660a
...
...
@@ -22,7 +22,7 @@ from __future__ import print_function
from
gevent
import
monkey
monkey
.
patch_all
(
thread
=
False
)
monkey
.
patch_all
()
from
contextlib
import
contextmanager
try
:
...
...
src/gevent/tests/test__queue.py
View file @
9535660a
import
unittest
import
gevent.testing
as
greentest
from
gevent.testing
import
TestCase
,
main
from
gevent.testing
import
TestCase
import
gevent
from
gevent.hub
import
get_hub
,
LoopExit
from
gevent
import
util
...
...
@@ -462,4 +462,4 @@ del AbstractGenericGetTestCase
if
__name__
==
'__main__'
:
main
()
greentest
.
main
()
src/gevent/tests/test__real_greenlet.py
View file @
9535660a
...
...
@@ -6,24 +6,29 @@ Fails with PyPy 2.2.1
"""
from
__future__
import
print_function
import
sys
import
greenlet
from
gevent
import
testing
as
greentest
print
(
'Your greenlet version: %s'
%
(
getattr
(
greenlet
,
'__version__'
,
None
),
))
class
Test
(
greentest
.
TestCase
):
def
test
(
self
):
import
greenlet
result
=
[]
print
(
'Your greenlet version: %s'
%
(
getattr
(
greenlet
,
'__version__'
,
None
),
))
result
=
[]
def
func
():
result
.
append
(
repr
(
sys
.
exc_info
()))
def
func
():
result
.
append
(
repr
(
sys
.
exc_info
()))
g
=
greenlet
.
greenlet
(
func
)
try
:
1
/
0
except
ZeroDivisionError
:
g
.
switch
()
g
=
greenlet
.
greenlet
(
func
)
try
:
1
/
0
except
ZeroDivisionError
:
g
.
switch
()
self
.
assertEqual
(
result
,
[
'(None, None, None)'
])
assert
result
==
[
'(None, None, None)'
],
result
if
__name__
==
'__main__'
:
greentest
.
main
()
src/gevent/tests/test__server.py
View file @
9535660a
...
...
@@ -140,7 +140,10 @@ class TestCase(greentest.TestCase):
conn
.
close
()
ex
=
exc
.
exception
self
.
assertIn
(
ex
.
args
[
0
],
(
errno
.
ECONNREFUSED
,
errno
.
EADDRNOTAVAIL
),
ex
)
self
.
assertIn
(
ex
.
args
[
0
],
(
errno
.
ECONNREFUSED
,
errno
.
EADDRNOTAVAIL
,
errno
.
ECONNRESET
,
errno
.
ECONNABORTED
),
(
ex
,
ex
.
args
))
def
assert500
(
self
):
self
.
Settings
.
assert500
(
self
)
...
...
src/gevent/tests/test__socket.py
View file @
9535660a
...
...
@@ -49,7 +49,7 @@ class Thread(_Thread):
class
TestTCP
(
greentest
.
TestCase
):
maxDiff
=
None
__timeout__
=
None
TIMEOUT_ERROR
=
socket
.
timeout
long_data
=
", "
.
join
([
str
(
x
)
for
x
in
range
(
20000
)])
...
...
@@ -210,7 +210,9 @@ class TestTCP(greentest.TestCase):
if
match_data
is
None
:
match_data
=
self
.
long_data
self
.
assertEqual
(
read_data
,
[
match_data
])
read_data
=
read_data
[
0
].
split
(
b','
)
match_data
=
match_data
.
split
(
b','
)
self
.
assertEqual
(
read_data
,
match_data
)
def
test_sendall_str
(
self
):
self
.
_test_sendall
(
self
.
long_data
)
...
...
src/gevent/tests/test__threading.py
View file @
9535660a
"""
Tests specifically for the monkey-patched threading module.
"""
from
gevent
import
monkey
;
monkey
.
patch_all
()
from
gevent
import
monkey
;
monkey
.
patch_all
()
# pragma: testrunner-no-monkey-combine
import
gevent.hub
# check that the locks initialized by 'threading' did not init the hub
...
...
src/gevent/tests/test__threading_before_monkey.py
View file @
9535660a
...
...
@@ -3,7 +3,7 @@
import
threading
from
gevent
import
monkey
monkey
.
patch_all
()
monkey
.
patch_all
()
# pragma: testrunner-no-monkey-combine
import
gevent.testing
as
greentest
...
...
src/gevent/tests/test__threading_holding_lock_while_monkey.py
View file @
9535660a
...
...
@@ -5,4 +5,4 @@ import threading
# in python code, this used to throw RuntimeErro("Cannot release un-acquired lock")
# See https://github.com/gevent/gevent/issues/615
with
threading
.
RLock
():
monkey
.
patch_all
()
monkey
.
patch_all
()
# pragma: testrunner-no-monkey-combine
src/gevent/tests/test__threading_monkey_in_thread.py
View file @
9535660a
...
...
@@ -25,7 +25,7 @@ class Test(greentest.TestCase):
def
target
():
tcurrent
=
threading
.
current_thread
()
monkey
.
patch_all
()
monkey
.
patch_all
()
# pragma: testrunner-no-monkey-combine
tcurrent2
=
threading
.
current_thread
()
self
.
assertIsNot
(
tcurrent
,
current
)
# We get a dummy thread now
...
...
src/gevent/tests/test__threading_native_before_monkey.py
View file @
9535660a
...
...
@@ -52,6 +52,6 @@ if __name__ == '__main__':
# Only patch after we're running
from
gevent
import
monkey
monkey
.
patch_all
()
monkey
.
patch_all
()
# pragma: testrunner-no-monkey-combine
greentest
.
main
()
src/gevent/tests/test__threading_vs_settrace.py
View file @
9535660a
...
...
@@ -7,7 +7,7 @@ import gevent.testing as greentest
script
=
"""
from gevent import monkey
monkey.patch_all()
monkey.patch_all()
# pragma: testrunner-no-monkey-combine
import sys, os, threading, time
...
...
src/gevent/tests/test__util.py
View file @
9535660a
...
...
@@ -142,6 +142,7 @@ class TestTree(greentest.TestCase):
value
=
re
.
compile
(
' fileno=.'
).
sub
(
''
,
value
)
value
=
value
.
replace
(
'ref=-1'
,
'ref=0'
)
value
=
value
.
replace
(
"type.current_tree"
,
'GreenletTree.current_tree'
)
value
=
value
.
replace
(
'gevent.tests.__main__.MyLocal'
,
'__main__.MyLocal'
)
return
value
@
greentest
.
ignores_leakcheck
...
...
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