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
d4d19fb0
Commit
d4d19fb0
authored
Nov 08, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get the tests running.
parent
71b5c5cf
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
151 additions
and
53 deletions
+151
-53
.gitignore
.gitignore
+3
-3
.pylintrc
.pylintrc
+1
-1
Makefile
Makefile
+9
-12
src/gevent/testing/testrunner.py
src/gevent/testing/testrunner.py
+6
-4
src/gevent/testing/util.py
src/gevent/testing/util.py
+24
-1
src/gevent/tests/2_7_keycert.pem
src/gevent/tests/2_7_keycert.pem
+31
-0
src/gevent/tests/__init__.py
src/gevent/tests/__init__.py
+0
-0
src/gevent/tests/__main__.py
src/gevent/tests/__main__.py
+18
-0
src/gevent/tests/test___monkey_patching.py
src/gevent/tests/test___monkey_patching.py
+8
-0
src/gevent/tests/test__doctests.py
src/gevent/tests/test__doctests.py
+43
-27
src/gevent/tests/test__example_udp_client.py
src/gevent/tests/test__example_udp_client.py
+7
-4
src/gevent/tests/test__makefile_ref.py
src/gevent/tests/test__makefile_ref.py
+1
-1
No files found.
.gitignore
View file @
d4d19fb0
...
...
@@ -35,9 +35,9 @@ Makefile.ext
MANIFEST
*_flymake.py
src/g
reentest
/.coverage\.*
src/greentest/htmlcov
src/greentest/
.coverage
src/g
event/tests
/.coverage\.*
htmlcov/
.coverage
doc/_build
doc/__pycache__
...
...
.pylintrc
View file @
d4d19fb0
...
...
@@ -98,7 +98,7 @@ ignored-classes=SSLContext, SSLSocket, greenlet, Greenlet, parent, dead
# (useful for modules/projects where namespaces are manipulated during runtime
# and thus existing member attributes cannot be deduced by static analysis. It
# supports qualified module names, as well as Unix pattern matching.
ignored-modules=gevent._corecffi,gevent.os,os,greenlet,threading,gevent.libev.corecffi
ignored-modules=gevent._corecffi,gevent.os,os,greenlet,threading,gevent.libev.corecffi
,gevent.socket,gevent.core
[DESIGN]
max-attributes=12
...
...
Makefile
View file @
d4d19fb0
...
...
@@ -22,7 +22,7 @@ clean:
rm
-rf
src/gevent/libev/
*
.o src/gevent/libuv/
*
.o src/gevent/
*
.o
rm
-rf
src/gevent/__pycache__ src/greentest/__pycache__ src/greentest/greentest/__pycache__ src/gevent/libev/__pycache__
rm
-rf
src/gevent/
*
.pyc src/greentest/
*
.pyc src/gevent/libev/
*
.pyc
rm
-rf
src/greentest/htmlcov src/greentest/
.coverage
rm
-rf
htmlcov
.coverage
rm
-rf
build
distclean
:
clean
...
...
@@ -57,28 +57,25 @@ test_prelim:
basictest
:
test_prelim
@
${PYTHON}
scripts/travis.py fold_start basictest
"Running basic tests"
cd
src/greentest
&&
GEVENT_RESOLVER
=
thread
${PYTHON}
testrunner.py
--config
known_failures.py
--quiet
GEVENT_RESOLVER
=
thread
${PYTHON}
-mgevent
.tests
--config
known_failures.py
--quiet
@
${PYTHON}
scripts/travis.py fold_end basictest
alltest
:
basictest
@
${PYTHON}
scripts/travis.py fold_start ares
"Running c-ares tests"
cd
src/greentest
&&
GEVENT_RESOLVER
=
ares
${PYTHON}
testrunner.py
--config
known_failures.py
--ignore
tests_that_dont_use_resolver.txt
--quiet
GEVENT_RESOLVER
=
ares
${PYTHON}
-mgevent
.tests
--config
known_failures.py
--ignore
tests_that_dont_use_resolver.txt
--quiet
@
${PYTHON}
scripts/travis.py fold_end ares
@
${PYTHON}
scripts/travis.py fold_start dnspython
"Running dnspython tests"
cd
src/greentest
&&
GEVENT_RESOLVER
=
dnspython
${PYTHON}
testrunner.py
--config
known_failures.py
--ignore
tests_that_dont_use_resolver.txt
--quiet
GEVENT_RESOLVER
=
dnspython
${PYTHON}
-mgevent
.tests
--config
known_failures.py
--ignore
tests_that_dont_use_resolver.txt
--quiet
@
${PYTHON}
scripts/travis.py fold_end dnspython
# In the past, we included all test files that had a reference to 'subprocess'' somewhere in their
# text. The monkey-patched stdlib tests were specifically included here.
# However, we now always also test on AppVeyor (Windows) which only has GEVENT_FILE=thread,
# so we can save a lot of CI time by reducing the set and excluding the stdlib tests without
# losing any coverage.
See the `threadfiletest` for what command used to run.
# losing any coverage.
@${PYTHON}
scripts/travis.py
fold_start
thread
"Running GEVENT_FILE=thread tests"
cd
src/g
reentest
&&
GEVENT_FILE
=
thread
${PYTHON}
testrunner.py
--config
known_failures.py test__
*
subprocess
*
.py
--quiet
cd
src/g
event/tests
&&
GEVENT_FILE
=
thread
${PYTHON}
-mgevent
.tests
--config
known_failures.py test__
*
subprocess
*
.py
--quiet
@${PYTHON}
scripts/travis.py
fold_end
thread
threadfiletest
:
cd
src/greentest
&&
GEVENT_FILE
=
thread
${PYTHON}
testrunner.py
--config
known_failures.py
`
grep
-l
subprocess test_
*
.py
`
--quiet
allbackendtest
:
@
${PYTHON}
scripts/travis.py fold_start default
"Testing default backend"
GEVENTTEST_COVERAGE
=
1 make alltest
...
...
@@ -99,7 +96,7 @@ cffibackendtest:
leaktest
:
test_prelim
@
${PYTHON}
scripts/travis.py fold_start leaktest
"Running leak tests"
cd
src/greentest
&&
GEVENT_RESOLVER
=
thread
GEVENTTEST_LEAKCHECK
=
1
${PYTHON}
testrunner.py
--config
known_failures.py
--quiet
--ignore
tests_that_dont_do_leakchecks.txt
GEVENT_RESOLVER
=
thread
GEVENTTEST_LEAKCHECK
=
1
${PYTHON}
-mgevent
.tests
--config
known_failures.py
--quiet
--ignore
tests_that_dont_do_leakchecks.txt
@
${PYTHON}
scripts/travis.py fold_end leaktest
@
${PYTHON}
scripts/travis.py fold_start default
"Testing default backend pure python"
PURE_PYTHON
=
1
GEVENTTEST_COVERAGE
=
1 make basictest
...
...
@@ -114,8 +111,8 @@ travis_test_linters:
make cffibackendtest
coverage_combine
:
coverage combine
.
src/g
reentest
/
-
coveralls
--rcfile
=
src/g
reentest
/.coveragerc
coverage combine
.
src/g
event/tests
/
-
coveralls
--rcfile
=
src/g
event/tests
/.coveragerc
.PHONY
:
clean doc prospector lint travistest travis
...
...
src/gevent/testing/testrunner.py
View file @
d4d19fb0
...
...
@@ -235,6 +235,7 @@ def discover(tests=None, ignore_files=None,
# Thus, be sure to open and compare in binary mode.
contents
=
f
.
read
()
if
b'TESTRUNNER'
in
contents
:
# test__monkey_patching.py
# XXX: Rework this to avoid importing.
module
=
__import__
(
filename
.
rsplit
(
'.'
,
1
)[
0
])
for
cmd
,
options
in
module
.
TESTRUNNER
():
if
remove_options
(
cmd
)[
-
1
]
in
ignore
:
...
...
@@ -260,10 +261,11 @@ def remove_options(lst):
def
load_list_from_file
(
filename
):
result
=
[]
if
filename
:
for
x
in
open
(
filename
):
x
=
x
.
split
(
'#'
,
1
)[
0
].
strip
()
if
x
:
result
.
append
(
x
)
with
open
(
filename
)
as
f
:
for
x
in
f
:
x
=
x
.
split
(
'#'
,
1
)[
0
].
strip
()
if
x
:
result
.
append
(
x
)
return
result
...
...
src/gevent/testing/util.py
View file @
d4d19fb0
...
...
@@ -298,8 +298,18 @@ def run(command, **kwargs):
return
RunResult
(
result
,
out
,
name
)
def
find_setup_py_above
(
a_file
):
"Return the directory containing setup.py somewhere above *a_file*"
root
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
a_file
))
while
not
os
.
path
.
exists
(
os
.
path
.
join
(
root
,
'setup.py'
)):
prev
,
root
=
root
,
os
.
path
.
dirname
(
root
)
if
root
==
prev
:
# Let's avoid infinite loops at root
raise
AssertionError
(
'could not find my setup.py'
)
return
root
class
TestServer
(
unittest
.
TestCase
):
cwd
=
'../../examples/'
args
=
[]
before_delay
=
3
after_delay
=
0.5
...
...
@@ -307,6 +317,19 @@ class TestServer(unittest.TestCase):
server
=
None
# subclasses define this to be the path to the server.py
start_kwargs
=
None
def
find_setup_py
(
self
):
"Return the directory containing setup.py"
return
find_setup_py_above
(
__file__
)
# XXX: We need to extend this if we want it to be useful
# for other packages; our __file__ won't work for them.
# We can look at the CWD, and we can look at the __file__ of the
# sys.modules[type(self).__module__].
@
property
def
cwd
(
self
):
root
=
self
.
find_setup_py
()
return
os
.
path
.
join
(
root
,
'examples'
)
def
start
(
self
):
kwargs
=
self
.
start_kwargs
or
{}
return
start
([
sys
.
executable
,
'-u'
,
self
.
server
]
+
self
.
args
,
cwd
=
self
.
cwd
,
**
kwargs
)
...
...
src/gevent/tests/2_7_keycert.pem
0 → 100644
View file @
d4d19fb0
-----BEGIN PRIVATE KEY-----
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANtb0+YrKuxevGpm
LrjaUhZSgz6zFAmuGFmKmUbdjmfv9zSmmdsQIksK++jK0Be9LeZy20j6ahOfuVa0
ufEmPoP7Fy4hXegKZR9cCWcIe/A6H2xWF1IIJLRTLaU8ol/I7T+um5HD5AwAwNPP
USNU0Eegmvp+xxWu3NX2m1Veot85AgMBAAECgYA3ZdZ673X0oexFlq7AAmrutkHt
CL7LvwrpOiaBjhyTxTeSNWzvtQBkIU8DOI0bIazA4UreAFffwtvEuPmonDb3F+Iq
SMAu42XcGyVZEl+gHlTPU9XRX7nTOXVt+MlRRRxL6t9GkGfUAXI3XxJDXW3c0vBK
UL9xqD8cORXOfE06rQJBAP8mEX1ERkR64Ptsoe4281vjTlNfIbs7NMPkUnrn9N/Y
BLhjNIfQ3HFZG8BTMLfX7kCS9D593DW5tV4Z9BP/c6cCQQDcFzCcVArNh2JSywOQ
ZfTfRbJg/Z5Lt9Fkngv1meeGNPgIMLN8Sg679pAOOWmzdMO3V706rNPzSVMME7E5
oPIfAkEA8pDddarP5tCvTTgUpmTFbakm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CRlNBAAlvhKzO7Clpf9l0YKBEfraJByX
-----END CERTIFICATE-----
src/gevent/tests/__init__.py
0 → 100644
View file @
d4d19fb0
src/gevent/tests/
testrunner
.py
→
src/gevent/tests/
__main__
.py
View file @
d4d19fb0
...
...
@@ -2,5 +2,17 @@
from
__future__
import
print_function
,
absolute_import
,
division
if
__name__
==
'__main__'
:
# We expect to be running in this directory, to do test discovery
# etc, automatically.
import
os
import
os.path
this_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
os
.
chdir
(
this_dir
)
# We also expect this directory to be on the path, because we
# try to import some test files by their bare name
import
sys
sys
.
path
.
append
(
this_dir
)
from
gevent.testing
import
testrunner
testrunner
.
main
()
src/gevent/tests/test___monkey_patching.py
View file @
d4d19fb0
...
...
@@ -7,12 +7,20 @@ import atexit
from
gevent.testing
import
util
# XXX: Generalize this so other packages can use it.
setup_py
=
util
.
find_setup_py_above
(
__file__
)
greentest
=
os
.
path
.
join
(
setup_py
,
'src'
,
'greentest'
)
TIMEOUT
=
120
directory
=
'%s.%s'
%
sys
.
version_info
[:
2
]
full_directory
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
if
hasattr
(
sys
,
'pypy_version_info'
):
directory
+=
'pypy'
full_directory
+=
'pypy'
directory
=
os
.
path
.
join
(
greentest
,
directory
)
full_directory
=
os
.
path
.
join
(
greentest
,
full_directory
)
version
=
'%s.%s.%s'
%
sys
.
version_info
[:
3
]
if
sys
.
version_info
[
3
]
==
'alpha'
:
version
+=
'a%s'
%
sys
.
version_info
[
4
]
...
...
src/gevent/tests/test__doctests.py
View file @
d4d19fb0
from
__future__
import
print_function
import
doctest
import
functools
import
os
import
re
import
sys
import
traceback
import
unittest
import
gevent
from
gevent
import
socket
from
gevent.testing
import
walk_modules
from
gevent.testing
import
sysinfo
from
gevent.testing
import
util
# Ignore tracebacks: ZeroDivisionError
def
myfunction
(
*
args
,
**
kwargs
):
def
myfunction
(
*
_args
,
**
_
kwargs
):
pass
...
...
@@ -44,29 +45,44 @@ if sysinfo.WIN:
'gevent.subprocess'
,
}
if
__name__
==
'__main__'
:
class
Modules
(
object
):
def
__init__
(
self
,
allowed_modules
):
self
.
allowed_modules
=
allowed_modules
self
.
modules
=
set
()
for
path
,
module
in
walk_modules
():
self
.
add_module
(
module
,
path
)
def
add_module
(
self
,
name
,
path
):
if
self
.
allowed_modules
and
name
not
in
self
.
allowed_modules
:
return
if
name
in
FORBIDDEN_MODULES
:
return
self
.
modules
.
add
((
name
,
path
))
def
__bool__
(
self
):
return
bool
(
self
.
modules
)
__nonzero__
=
__bool__
def
__iter__
(
self
):
return
iter
(
self
.
modules
)
def
main
():
cwd
=
os
.
getcwd
()
try
:
allowed_modules
=
sys
.
argv
[
1
:]
sys
.
path
.
append
(
'.'
)
base
=
os
.
path
.
dirname
(
gevent
.
__file__
)
print
(
base
)
os
.
chdir
(
'../..'
)
os
.
chdir
(
util
.
find_setup_py_above
(
__file__
))
globs
=
{
'myfunction'
:
myfunction
,
'gevent'
:
gevent
,
'socket'
:
socket
}
modules
=
set
(
)
modules
=
Modules
(
allowed_modules
)
def
add_module
(
name
,
path
):
if
allowed_modules
and
name
not
in
allowed_modules
:
return
if
name
in
FORBIDDEN_MODULES
:
return
modules
.
add
((
name
,
path
))
for
path
,
module
in
walk_modules
():
add_module
(
module
,
path
)
add_module
(
'setup'
,
'setup.py'
)
modules
.
add_module
(
'setup'
,
'setup.py'
)
if
not
modules
:
sys
.
exit
(
'No modules found matching %s'
%
' '
.
join
(
allowed_modules
))
...
...
@@ -88,18 +104,18 @@ if __name__ == '__main__':
with
open
(
path
,
'rb'
)
as
f
:
contents
=
f
.
read
()
if
re
.
search
(
br'^\
s*>>>
', contents, re.M):
try:
s = doctest.DocTestSuite(m, extraglobs=globs, checker=checker)
test_count = len(s._tests) # pylint: disable=W0212
print('
%
s
(
from
%
s
):
%
s
tests
' % (m, path, test_count))
suite.addTest(s)
modules_count += 1
tests_count += test_count
except Exception:
traceback.print_exc()
sys.stderr.write('
Failed
to
process
%
s
\
n
\
n
' % path)
s = doctest.DocTestSuite(m, extraglobs=globs, checker=checker)
test_count = len(s._tests)
print('
%
s
(
from
%
s
):
%
s
tests
' % (m, path, test_count))
suite.addTest(s)
modules_count += 1
tests_count += test_count
print('
Total
:
%
s
tests
in
%
s
modules
' % (tests_count, modules_count))
# TODO: Pass this off to unittest.main()
runner = unittest.TextTestRunner(verbosity=2)
runner.run(suite)
finally:
os.chdir(cwd)
if __name__ == '
__main__
':
main()
src/gevent/tests/test__example_udp_client.py
View file @
d4d19fb0
from
gevent
import
monkey
;
monkey
.
patch_all
(
subprocess
=
True
)
from
gevent
import
monkey
monkey
.
patch_all
(
subprocess
=
True
)
import
sys
from
gevent.server
import
DatagramServer
from
unittest
import
TestCase
from
gevent.testing.util
import
run
from
gevent.testing
import
util
from
gevent.testing
import
main
class
Test_udp_client
(
TestCase
):
class
Test_udp_client
(
util
.
TestServer
):
def
test
(
self
):
log
=
[]
...
...
@@ -18,7 +21,7 @@ class Test_udp_client(TestCase):
server
.
start
()
try
:
run
([
sys
.
executable
,
'-W'
,
'ignore'
,
'-u'
,
'udp_client.py'
,
'Test_udp_client'
],
timeout
=
10
,
cwd
=
'../../examples/'
)
timeout
=
10
,
cwd
=
self
.
cwd
)
finally
:
server
.
close
()
self
.
assertEqual
(
log
,
[
b'Test_udp_client'
])
...
...
src/gevent/tests/test__makefile_ref.py
View file @
d4d19fb0
...
...
@@ -13,7 +13,7 @@ import gevent.testing as greentest
dirname
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
certfile
=
os
.
path
.
join
(
dirname
,
'2
.7/
keycert.pem'
)
certfile
=
os
.
path
.
join
(
dirname
,
'2
_7_
keycert.pem'
)
pid
=
os
.
getpid
()
PY3
=
greentest
.
PY3
...
...
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