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
f5da156b
Commit
f5da156b
authored
Nov 08, 2018
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix pylint errors in our tests.
parent
d4d19fb0
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
119 additions
and
95 deletions
+119
-95
CHANGES.rst
CHANGES.rst
+4
-0
doc/install.rst
doc/install.rst
+2
-4
src/gevent/tests/lock_tests.py
src/gevent/tests/lock_tests.py
+11
-10
src/gevent/tests/test__all__.py
src/gevent/tests/test__all__.py
+1
-1
src/gevent/tests/test__api.py
src/gevent/tests/test__api.py
+5
-3
src/gevent/tests/test__core_fork.py
src/gevent/tests/test__core_fork.py
+2
-1
src/gevent/tests/test__core_loop_run_sig_mod.py
src/gevent/tests/test__core_loop_run_sig_mod.py
+4
-4
src/gevent/tests/test__core_timer.py
src/gevent/tests/test__core_timer.py
+1
-1
src/gevent/tests/test__execmodules.py
src/gevent/tests/test__execmodules.py
+12
-10
src/gevent/tests/test__greenletset.py
src/gevent/tests/test__greenletset.py
+1
-1
src/gevent/tests/test__issue467.py
src/gevent/tests/test__issue467.py
+1
-1
src/gevent/tests/test__local.py
src/gevent/tests/test__local.py
+1
-1
src/gevent/tests/test__memleak.py
src/gevent/tests/test__memleak.py
+7
-5
src/gevent/tests/test__monkey_logging.py
src/gevent/tests/test__monkey_logging.py
+1
-1
src/gevent/tests/test__monkey_sigchld.py
src/gevent/tests/test__monkey_sigchld.py
+1
-1
src/gevent/tests/test__monkey_sigchld_3.py
src/gevent/tests/test__monkey_sigchld_3.py
+3
-3
src/gevent/tests/test__pool.py
src/gevent/tests/test__pool.py
+1
-1
src/gevent/tests/test__pywsgi.py
src/gevent/tests/test__pywsgi.py
+4
-2
src/gevent/tests/test__refcount.py
src/gevent/tests/test__refcount.py
+7
-6
src/gevent/tests/test__server.py
src/gevent/tests/test__server.py
+2
-2
src/gevent/tests/test__signal.py
src/gevent/tests/test__signal.py
+2
-2
src/gevent/tests/test__socket.py
src/gevent/tests/test__socket.py
+2
-2
src/gevent/tests/test__socket_dns.py
src/gevent/tests/test__socket_dns.py
+10
-8
src/gevent/tests/test__socket_ssl.py
src/gevent/tests/test__socket_ssl.py
+11
-6
src/gevent/tests/test__ssl.py
src/gevent/tests/test__ssl.py
+1
-1
src/gevent/tests/test__subprocess.py
src/gevent/tests/test__subprocess.py
+3
-4
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_patched_local.py
src/gevent/tests/test__threading_patched_local.py
+2
-1
src/gevent/tests/test__timeout.py
src/gevent/tests/test__timeout.py
+2
-2
src/gevent/tests/test_threading_2.py
src/gevent/tests/test_threading_2.py
+14
-10
No files found.
CHANGES.rst
View file @
f5da156b
...
@@ -42,6 +42,10 @@
...
@@ -42,6 +42,10 @@
Objects/tupleobject.c: bad argument to internal function``. Reported
Objects/tupleobject.c: bad argument to internal function``. Reported
in :issue:`1302` by Ulrich Petri.
in :issue:`1302` by Ulrich Petri.
- Refactored the gevent test runner and test suite to make them more
reusable. In particular, the tests are now run with ``python -m
gevent.tests``. See :issue:`1293`.
1.3.7 (2018-10-12)
1.3.7 (2018-10-12)
==================
==================
...
...
doc/install.rst
View file @
f5da156b
...
@@ -177,8 +177,7 @@ tests on one version of Python during development, begin with the
...
@@ -177,8 +177,7 @@ tests on one version of Python during development, begin with the
above instructions to install gevent in a virtual environment and then
above instructions to install gevent in a virtual environment and then
run::
run::
(env) $ cd src/greentest
(env) $ python -mgevent.tests
(env) $ python ./testrunner.py
Before submitting a pull request, it's a good idea to run the tests
Before submitting a pull request, it's a good idea to run the tests
across all supported versions of Python, and to check the code quality
across all supported versions of Python, and to check the code quality
...
@@ -192,8 +191,7 @@ The testrunner accepts a ``--coverage`` argument to enable code
...
@@ -192,8 +191,7 @@ The testrunner accepts a ``--coverage`` argument to enable code
coverage metrics through the `coverage.py`_ package. That would go
coverage metrics through the `coverage.py`_ package. That would go
something like this::
something like this::
cd src/greentest
python -m gevent.tests --coverage
python testrunner.py --coverage
coverage combine
coverage combine
coverage html -i
coverage html -i
<open htmlcov/index.html>
<open htmlcov/index.html>
...
...
src/gevent/tests/lock_tests.py
View file @
f5da156b
"""
"""
Various tests for synchronization primitives.
Various tests for synchronization primitives.
"""
"""
# pylint:disable=no-member,abstract-method
import
sys
import
sys
import
time
import
time
try
:
try
:
...
@@ -131,7 +132,7 @@ class BaseLockTests(BaseTestCase):
...
@@ -131,7 +132,7 @@ class BaseLockTests(BaseTestCase):
def
_with
(
err
=
None
):
def
_with
(
err
=
None
):
with
lock
:
with
lock
:
if
err
is
not
None
:
if
err
is
not
None
:
raise
err
raise
err
# pylint:disable=raising-bad-type
_with
()
_with
()
# Check the lock is unacquired
# Check the lock is unacquired
Bunch
(
f
,
1
).
wait_for_finished
()
Bunch
(
f
,
1
).
wait_for_finished
()
...
@@ -153,7 +154,7 @@ class BaseLockTests(BaseTestCase):
...
@@ -153,7 +154,7 @@ class BaseLockTests(BaseTestCase):
self
.
assertEqual
(
n
,
len
(
threading
.
enumerate
()))
self
.
assertEqual
(
n
,
len
(
threading
.
enumerate
()))
class
LockTests
(
BaseLockTests
):
class
LockTests
(
BaseLockTests
):
# pylint:disable=abstract-method
"""
"""
Tests for non-recursive, weak locks
Tests for non-recursive, weak locks
(which can be acquired and released from different threads).
(which can be acquired and released from different threads).
...
@@ -168,7 +169,7 @@ class LockTests(BaseLockTests):
...
@@ -168,7 +169,7 @@ class LockTests(BaseLockTests):
lock
.
acquire
()
lock
.
acquire
()
phase
.
append
(
None
)
phase
.
append
(
None
)
start_new_thread
(
f
,
())
start_new_thread
(
f
,
())
while
len
(
phase
)
==
0
:
while
not
phase
:
_wait
()
_wait
()
_wait
()
_wait
()
self
.
assertEqual
(
len
(
phase
),
1
)
self
.
assertEqual
(
len
(
phase
),
1
)
...
@@ -436,9 +437,10 @@ class BaseSemaphoreTests(BaseTestCase):
...
@@ -436,9 +437,10 @@ class BaseSemaphoreTests(BaseTestCase):
raise
NotImplementedError
()
raise
NotImplementedError
()
def
test_constructor
(
self
):
def
test_constructor
(
self
):
self
.
assertRaises
(
ValueError
,
self
.
semtype
,
value
=
-
1
)
self
.
assertRaises
(
ValueError
,
self
.
semtype
,
value
=
-
1
)
# Py3 doesn't have sys.maxint
# Py3 doesn't have sys.maxint
self
.
assertRaises
(
ValueError
,
self
.
semtype
,
value
=
-
getattr
(
sys
,
'maxint'
,
getattr
(
sys
,
'maxsize'
,
None
)))
self
.
assertRaises
(
ValueError
,
self
.
semtype
,
value
=-
getattr
(
sys
,
'maxint'
,
getattr
(
sys
,
'maxsize'
,
None
)))
def
test_acquire
(
self
):
def
test_acquire
(
self
):
sem
=
self
.
semtype
(
1
)
sem
=
self
.
semtype
(
1
)
...
@@ -509,7 +511,7 @@ class BaseSemaphoreTests(BaseTestCase):
...
@@ -509,7 +511,7 @@ class BaseSemaphoreTests(BaseTestCase):
# There can be a thread switch between acquiring the semaphore and
# There can be a thread switch between acquiring the semaphore and
# appending the result, therefore results will not necessarily be
# appending the result, therefore results will not necessarily be
# ordered.
# ordered.
self
.
assertEqual
(
sorted
(
results
),
[
False
]
*
7
+
[
True
]
*
3
)
self
.
assertEqual
(
sorted
(
results
),
[
False
]
*
7
+
[
True
]
*
3
)
def
test_default_value
(
self
):
def
test_default_value
(
self
):
# The default initial value is 1.
# The default initial value is 1.
...
@@ -534,7 +536,7 @@ class BaseSemaphoreTests(BaseTestCase):
...
@@ -534,7 +536,7 @@ class BaseSemaphoreTests(BaseTestCase):
with
sem
:
with
sem
:
self
.
assertFalse
(
sem
.
acquire
(
False
))
self
.
assertFalse
(
sem
.
acquire
(
False
))
if
err
:
if
err
:
raise
err
raise
err
# pylint:disable=raising-bad-type
_with
()
_with
()
self
.
assertTrue
(
sem
.
acquire
(
False
))
self
.
assertTrue
(
sem
.
acquire
(
False
))
sem
.
release
()
sem
.
release
()
...
@@ -603,7 +605,7 @@ class BarrierTests(BaseTestCase):
...
@@ -603,7 +605,7 @@ class BarrierTests(BaseTestCase):
"""
"""
Test that a barrier is passed in lockstep
Test that a barrier is passed in lockstep
"""
"""
results
=
[[],[]]
results
=
[[],
[]]
def
f
():
def
f
():
self
.
multipass
(
results
,
passes
)
self
.
multipass
(
results
,
passes
)
self
.
run_threads
(
f
)
self
.
run_threads
(
f
)
...
@@ -657,7 +659,6 @@ class BarrierTests(BaseTestCase):
...
@@ -657,7 +659,6 @@ class BarrierTests(BaseTestCase):
results2
.
append
(
True
)
results2
.
append
(
True
)
except
RuntimeError
:
except
RuntimeError
:
self
.
barrier
.
abort
()
self
.
barrier
.
abort
()
pass
self
.
run_threads
(
f
)
self
.
run_threads
(
f
)
self
.
assertEqual
(
len
(
results1
),
0
)
self
.
assertEqual
(
len
(
results1
),
0
)
...
@@ -713,7 +714,7 @@ class BarrierTests(BaseTestCase):
...
@@ -713,7 +714,7 @@ class BarrierTests(BaseTestCase):
results2
.
append
(
True
)
results2
.
append
(
True
)
except
RuntimeError
:
except
RuntimeError
:
self
.
barrier
.
abort
()
self
.
barrier
.
abort
()
pass
# Synchronize and reset the barrier. Must synchronize first so
# Synchronize and reset the barrier. Must synchronize first so
# that everyone has left it when we reset, and after so that no
# that everyone has left it when we reset, and after so that no
# one enters it before the reset.
# one enters it before the reset.
...
...
src/gevent/tests/test__all__.py
View file @
f5da156b
...
@@ -133,7 +133,7 @@ class Test(unittest.TestCase):
...
@@ -133,7 +133,7 @@ class Test(unittest.TestCase):
if
hasattr
(
self
.
stdlib_module
,
name
):
if
hasattr
(
self
.
stdlib_module
,
name
):
raise
AssertionError
(
"'%r' is not an extension, it is found in %r"
%
(
name
,
self
.
stdlib_module
))
raise
AssertionError
(
"'%r' is not an extension, it is found in %r"
%
(
name
,
self
.
stdlib_module
))
def
check_completeness
(
self
):
def
check_completeness
(
self
):
# pylint:disable=too-many-branches
"""Check that __all__ (or dir()) of the corresponsing stdlib is a subset of __all__ of this module"""
"""Check that __all__ (or dir()) of the corresponsing stdlib is a subset of __all__ of this module"""
missed
=
[]
missed
=
[]
for
name
in
self
.
stdlib_all
:
for
name
in
self
.
stdlib_all
:
...
...
src/gevent/tests/test__api.py
View file @
f5da156b
...
@@ -36,10 +36,10 @@ class Test(greentest.TestCase):
...
@@ -36,10 +36,10 @@ class Test(greentest.TestCase):
try
:
try
:
state
.
append
(
'start'
)
state
.
append
(
'start'
)
gevent
.
sleep
(
DELAY
*
3.0
)
gevent
.
sleep
(
DELAY
*
3.0
)
except
:
except
:
# pylint:disable=bare-except
state
.
append
(
'except'
)
state
.
append
(
'except'
)
# catching GreenletExit
# catching GreenletExit
pass
state
.
append
(
'finished'
)
state
.
append
(
'finished'
)
g
=
gevent
.
spawn
(
test
)
g
=
gevent
.
spawn
(
test
)
...
@@ -68,7 +68,9 @@ class Test(greentest.TestCase):
...
@@ -68,7 +68,9 @@ class Test(greentest.TestCase):
def
_test_wait_read_invalid_switch
(
self
,
sleep
):
def
_test_wait_read_invalid_switch
(
self
,
sleep
):
sock1
,
sock2
=
socket
.
socketpair
()
sock1
,
sock2
=
socket
.
socketpair
()
try
:
try
:
p
=
gevent
.
spawn
(
util
.
wrap_errors
(
AssertionError
,
socket
.
wait_read
),
sock1
.
fileno
())
p
=
gevent
.
spawn
(
util
.
wrap_errors
(
AssertionError
,
socket
.
wait_read
),
# pylint:disable=no-member
sock1
.
fileno
())
gevent
.
get_hub
().
loop
.
run_callback
(
switch_None
,
p
)
gevent
.
get_hub
().
loop
.
run_callback
(
switch_None
,
p
)
if
sleep
is
not
None
:
if
sleep
is
not
None
:
gevent
.
sleep
(
sleep
)
gevent
.
sleep
(
sleep
)
...
...
src/gevent/tests/test__core_fork.py
View file @
f5da156b
from
__future__
import
print_function
from
__future__
import
print_function
import
gevent.monkey
;
gevent
.
monkey
.
patch_all
()
import
gevent.monkey
gevent
.
monkey
.
patch_all
()
import
gevent
import
gevent
import
os
import
os
...
...
src/gevent/tests/test__core_loop_run_sig_mod.py
View file @
f5da156b
...
@@ -6,11 +6,11 @@ import test__core_loop_run # this runs main tests, fails if signal() is not call
...
@@ -6,11 +6,11 @@ import test__core_loop_run # this runs main tests, fails if signal() is not call
assert
test__core_loop_run
# pyflakes
assert
test__core_loop_run
# pyflakes
from
gevent.hub
import
signal
as
hub_signal
from
gevent.hub
import
signal
as
hub_signal
from
gevent
import
signal
from
gevent
import
signal
as
top_signal
# pylint:disable=reimported
assert
gevent
.
signal
is
hub_signal
assert
gevent
.
signal
is
hub_signal
assert
gevent
.
signal
is
signal
assert
gevent
.
signal
is
top_
signal
assert
hasattr
(
gevent
.
signal
,
'signal'
)
assert
hasattr
(
gevent
.
signal
,
'signal'
)
s
=
signal
(
2
,
sys
.
stderr
.
write
,
'INTERRUPT'
)
s
=
top_
signal
(
2
,
sys
.
stderr
.
write
,
'INTERRUPT'
)
assert
isinstance
(
s
,
signal
)
assert
isinstance
(
s
,
top_
signal
)
assert
isinstance
(
s
,
hub_signal
)
assert
isinstance
(
s
,
hub_signal
)
src/gevent/tests/test__core_timer.py
View file @
f5da156b
...
@@ -94,7 +94,7 @@ class TestTimerResolution(Test):
...
@@ -94,7 +94,7 @@ class TestTimerResolution(Test):
# On CI, with *all* backends, sometimes we get timer values of
# On CI, with *all* backends, sometimes we get timer values of
# 0.02 or higher.
# 0.02 or higher.
@
reraises_flaky_timeout
(
AssertionError
)
@
reraises_flaky_timeout
(
AssertionError
)
def
test_resolution
(
self
):
def
test_resolution
(
self
):
# pylint:disable=too-many-locals
# Make sure that having an active IO watcher
# Make sure that having an active IO watcher
# doesn't badly throw off our timer resolution.
# doesn't badly throw off our timer resolution.
# (This was a specific problem with libuv)
# (This was a specific problem with libuv)
...
...
src/gevent/tests/test__execmodules.py
View file @
f5da156b
...
@@ -14,7 +14,7 @@ class TestExec(unittest.TestCase):
...
@@ -14,7 +14,7 @@ class TestExec(unittest.TestCase):
def
make_exec_test
(
path
,
module
):
def
make_exec_test
(
path
,
module
):
def
test
(
self
):
def
test
(
_
):
#sys.stderr.write('%s %s\n' % (module, path))
#sys.stderr.write('%s %s\n' % (module, path))
with
open
(
path
,
'rb'
)
as
f
:
with
open
(
path
,
'rb'
)
as
f
:
src
=
f
.
read
()
src
=
f
.
read
()
...
@@ -24,18 +24,20 @@ def make_exec_test(path, module):
...
@@ -24,18 +24,20 @@ def make_exec_test(path, module):
test
.
__name__
=
name
test
.
__name__
=
name
setattr
(
TestExec
,
name
,
test
)
setattr
(
TestExec
,
name
,
test
)
def
make_all_tests
():
for
path
,
module
in
walk_modules
():
ignored
=
False
for
x
in
NON_APPLICABLE_SUFFIXES
:
if
module
.
endswith
(
x
):
ignored
=
True
break
if
ignored
:
continue
for
path
,
module
in
walk_modules
():
make_exec_test
(
path
,
module
)
ignored
=
False
for
x
in
NON_APPLICABLE_SUFFIXES
:
if
module
.
endswith
(
x
):
ignored
=
True
break
if
ignored
:
continue
make_exec_test
(
path
,
module
)
make_all_tests
()
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
src/gevent/tests/test__greenletset.py
View file @
f5da156b
...
@@ -142,7 +142,7 @@ class Test(greentest.TestCase):
...
@@ -142,7 +142,7 @@ class Test(greentest.TestCase):
def
f
():
def
f
():
try
:
try
:
gevent
.
sleep
(
1.5
)
gevent
.
sleep
(
1.5
)
except
:
except
:
# pylint:disable=bare-except
gevent
.
sleep
(
1
)
gevent
.
sleep
(
1
)
p1
=
GreenletSubclass
.
spawn
(
f
)
p1
=
GreenletSubclass
.
spawn
(
f
)
p2
=
GreenletSubclass
.
spawn
(
f
)
p2
=
GreenletSubclass
.
spawn
(
f
)
...
...
src/gevent/tests/test__issue467.py
View file @
f5da156b
...
@@ -23,7 +23,7 @@ def main():
...
@@ -23,7 +23,7 @@ def main():
workers
=
[
gevent
.
spawn
(
worker
,
i
)
for
i
in
range
(
3
)]
workers
=
[
gevent
.
spawn
(
worker
,
i
)
for
i
in
range
(
3
)]
workers
.
append
(
done_worker
)
workers
.
append
(
done_worker
)
for
g
in
gevent
.
iwait
(
workers
):
for
_
in
gevent
.
iwait
(
workers
):
finished
+=
1
finished
+=
1
# Simulate doing something that causes greenlets to switch;
# Simulate doing something that causes greenlets to switch;
# a non-zero timeout is crucial
# a non-zero timeout is crucial
...
...
src/gevent/tests/test__local.py
View file @
f5da156b
...
@@ -160,7 +160,7 @@ class TestGeventLocal(greentest.TestCase):
...
@@ -160,7 +160,7 @@ class TestGeventLocal(greentest.TestCase):
self
.
assertEqual
(
a
.
initialized
,
2
)
self
.
assertEqual
(
a
.
initialized
,
2
)
# The slot overrides dict values
# The slot overrides dict values
a
.
__dict__
[
'initialized'
]
=
42
a
.
__dict__
[
'initialized'
]
=
42
# pylint:disable=unsupported-assignment-operation
self
.
assertEqual
(
a
.
initialized
,
2
)
self
.
assertEqual
(
a
.
initialized
,
2
)
# Deleting the slot deletes the slot, but not the dict
# Deleting the slot deletes the slot, but not the dict
...
...
src/gevent/tests/test__memleak.py
View file @
f5da156b
import
sys
import
sys
import
unittest
from
gevent.testing
import
TestCase
,
main
from
gevent.testing
import
TestCase
,
main
import
gevent
import
gevent
from
gevent.timeout
import
Timeout
from
gevent.timeout
import
Timeout
@
unittest
.
skipUnless
(
hasattr
(
sys
,
'gettotalrefcount'
),
"Needs debug build"
)
class
TestQueue
(
TestCase
):
class
TestQueue
(
TestCase
):
# pylint:disable=bare-except,no-member
def
test
(
self
):
def
test
(
self
):
result
=
''
result
=
''
...
@@ -43,12 +47,10 @@ class TestQueue(TestCase):
...
@@ -43,12 +47,10 @@ class TestQueue(TestCase):
result
+=
'%s'
%
sys
.
gettotalrefcount
()
result
+=
'%s'
%
sys
.
gettotalrefcount
()
a
,
b
,
c
=
result
.
split
()
_
,
b
,
c
=
result
.
split
()
assert
b
==
c
,
'total refcount mismatch: %s'
%
result
assert
b
==
c
,
'total refcount mismatch: %s'
%
result
if
not
hasattr
(
sys
,
'gettotalrefcount'
):
del
TestQueue
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
src/gevent/tests/test__monkey_logging.py
View file @
f5da156b
...
@@ -16,7 +16,7 @@ def _inner_lock(lock):
...
@@ -16,7 +16,7 @@ def _inner_lock(lock):
def
checkLocks
(
kind
,
ignore_none
=
True
):
def
checkLocks
(
kind
,
ignore_none
=
True
):
handlers
=
logging
.
_handlerList
handlers
=
logging
.
_handlerList
assert
len
(
handlers
)
>
0
assert
handlers
for
weakref
in
handlers
:
for
weakref
in
handlers
:
# In py26, these are actual handlers, not weakrefs
# In py26, these are actual handlers, not weakrefs
...
...
src/gevent/tests/test__monkey_sigchld.py
View file @
f5da156b
...
@@ -11,7 +11,7 @@ pid = None
...
@@ -11,7 +11,7 @@ pid = None
awaiting_child
=
[]
awaiting_child
=
[]
def
handle_sigchld
(
*
args
):
def
handle_sigchld
(
*
_
args
):
# Make sure we can do a blocking operation
# Make sure we can do a blocking operation
gevent
.
sleep
()
gevent
.
sleep
()
# Signal completion
# Signal completion
...
...
src/gevent/tests/test__monkey_sigchld_3.py
View file @
f5da156b
...
@@ -16,12 +16,12 @@ import sys
...
@@ -16,12 +16,12 @@ import sys
import
signal
import
signal
import
subprocess
import
subprocess
def
_waitpid
(
p
id
):
def
_waitpid
(
p
):
try
:
try
:
_
,
stat
=
os
.
waitpid
(
p
id
,
0
)
_
,
stat
=
os
.
waitpid
(
p
,
0
)
except
OSError
:
except
OSError
:
# Interrupted system call
# Interrupted system call
_
,
stat
=
os
.
waitpid
(
p
id
,
0
)
_
,
stat
=
os
.
waitpid
(
p
,
0
)
assert
stat
==
0
,
stat
assert
stat
==
0
,
stat
if
hasattr
(
signal
,
'SIGCHLD'
):
if
hasattr
(
signal
,
'SIGCHLD'
):
...
...
src/gevent/tests/test__pool.py
View file @
f5da156b
...
@@ -78,7 +78,7 @@ class TestCoroutinePool(unittest.TestCase):
...
@@ -78,7 +78,7 @@ class TestCoroutinePool(unittest.TestCase):
timer_fired
.
append
(
True
)
timer_fired
.
append
(
True
)
def
some_work
():
def
some_work
():
gevent
.
timer
(
0
,
fire_timer
)
gevent
.
timer
(
0
,
fire_timer
)
# pylint:disable=no-member
pool
=
self
.
klass
(
2
)
pool
=
self
.
klass
(
2
)
pool
.
apply
(
some_work
)
pool
.
apply
(
some_work
)
...
...
src/gevent/tests/test__pywsgi.py
View file @
f5da156b
...
@@ -611,10 +611,12 @@ class TestChunkedPost(TestCase):
...
@@ -611,10 +611,12 @@ class TestChunkedPost(TestCase):
if
env
[
'PATH_INFO'
]
==
'/a'
:
if
env
[
'PATH_INFO'
]
==
'/a'
:
data
=
env
[
'wsgi.input'
].
read
(
6
)
data
=
env
[
'wsgi.input'
].
read
(
6
)
return
[
data
]
return
[
data
]
elif
env
[
'PATH_INFO'
]
==
'/b'
:
if
env
[
'PATH_INFO'
]
==
'/b'
:
lines
=
[
x
for
x
in
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
6
),
b''
)]
lines
=
[
x
for
x
in
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
6
),
b''
)]
return
lines
return
lines
elif
env
[
'PATH_INFO'
]
==
'/c'
:
if
env
[
'PATH_INFO'
]
==
'/c'
:
return
[
x
for
x
in
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
1
),
b''
)]
return
[
x
for
x
in
iter
(
lambda
:
env
[
'wsgi.input'
].
read
(
1
),
b''
)]
def
test_014_chunked_post
(
self
):
def
test_014_chunked_post
(
self
):
...
...
src/gevent/tests/test__refcount.py
View file @
f5da156b
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
are not leaked by the hub.
are not leaked by the hub.
"""
"""
from
__future__
import
print_function
from
__future__
import
print_function
from
_socket
import
socket
from
_socket
import
socket
as
c_socket
import
sys
import
sys
if
sys
.
version_info
[
0
]
>=
3
:
if
sys
.
version_info
[
0
]
>=
3
:
# Python3 enforces that __weakref__ appears only once,
# Python3 enforces that __weakref__ appears only once,
...
@@ -32,9 +32,9 @@ if sys.version_info[0] >= 3:
...
@@ -32,9 +32,9 @@ if sys.version_info[0] >= 3:
# (because socket.socket defines __slots__ with __weakref__),
# (because socket.socket defines __slots__ with __weakref__),
# so import socket.socket before that can happen.
# so import socket.socket before that can happen.
__import__
(
'socket'
)
__import__
(
'socket'
)
Socket
=
socket
Socket
=
c_
socket
else
:
else
:
class
Socket
(
socket
):
class
Socket
(
c_
socket
):
"Something we can have a weakref to"
"Something we can have a weakref to"
import
_socket
import
_socket
...
@@ -117,7 +117,7 @@ def run_interaction(run_client):
...
@@ -117,7 +117,7 @@ def run_interaction(run_client):
# strong refs to the socket still around.
# strong refs to the socket still around.
try
:
try
:
sleep
(
0.1
+
SOCKET_TIMEOUT
)
sleep
(
0.1
+
SOCKET_TIMEOUT
)
except
Exception
:
except
Exception
:
# pylint:disable=broad-except
pass
pass
return
w
return
w
...
@@ -139,8 +139,9 @@ def run_and_check(run_client):
...
@@ -139,8 +139,9 @@ def run_and_check(run_client):
@
greentest
.
skipOnCI
(
"Often fail with timeouts or force closed connections; not sure why."
)
@
greentest
.
skipOnCI
(
"Often fail with timeouts or force closed connections; not sure why."
)
@
greentest
.
skipIf
(
greentest
.
RUN_LEAKCHECKS
and
greentest
.
PY3
,
@
greentest
.
skipIf
(
"Often fail with force closed connections; not sure why. "
greentest
.
RUN_LEAKCHECKS
and
greentest
.
PY3
,
"Often fail with force closed connections; not sure why. "
)
)
class
Test
(
greentest
.
TestCase
):
class
Test
(
greentest
.
TestCase
):
...
...
src/gevent/tests/test__server.py
View file @
f5da156b
...
@@ -14,7 +14,7 @@ from gevent.server import StreamServer
...
@@ -14,7 +14,7 @@ from gevent.server import StreamServer
class
SimpleStreamServer
(
StreamServer
):
class
SimpleStreamServer
(
StreamServer
):
def
handle
(
self
,
client_socket
,
_address
):
def
handle
(
self
,
client_socket
,
_address
):
# pylint:disable=method-hidden
fd
=
client_socket
.
makefile
()
fd
=
client_socket
.
makefile
()
try
:
try
:
request_line
=
fd
.
readline
()
request_line
=
fd
.
readline
()
...
@@ -487,7 +487,7 @@ class TestSSLGetCertificate(TestCase):
...
@@ -487,7 +487,7 @@ class TestSSLGetCertificate(TestCase):
self
.
init_server
()
self
.
init_server
()
server_host
,
server_port
,
_family
=
self
.
get_server_host_port_family
()
server_host
,
server_port
,
_family
=
self
.
get_server_host_port_family
()
ssl
.
get_server_certificate
((
server_host
,
server_port
))
ssl
.
get_server_certificate
((
server_host
,
server_port
))
# pylint:disable=no-member
def
test_wrap_socket_and_handle_wrap_failure
(
self
):
def
test_wrap_socket_and_handle_wrap_failure
(
self
):
...
...
src/gevent/tests/test__signal.py
View file @
f5da156b
...
@@ -6,7 +6,7 @@ import pkg_resources
...
@@ -6,7 +6,7 @@ import pkg_resources
try
:
try
:
cffi_version
=
pkg_resources
.
get_distribution
(
'cffi'
).
parsed_version
cffi_version
=
pkg_resources
.
get_distribution
(
'cffi'
).
parsed_version
except
Exception
:
except
Exception
:
# pylint:disable=broad-except
# No cffi installed. Shouldn't happen to gevent standard tests,
# No cffi installed. Shouldn't happen to gevent standard tests,
# but maybe some downstream distributor removed it.
# but maybe some downstream distributor removed it.
cffi_version
=
None
cffi_version
=
None
...
@@ -50,7 +50,7 @@ if hasattr(signal, 'SIGALRM'):
...
@@ -50,7 +50,7 @@ if hasattr(signal, 'SIGALRM'):
except
Expected
as
ex
:
except
Expected
as
ex
:
assert
str
(
ex
)
==
'TestSignal'
,
ex
assert
str
(
ex
)
==
'TestSignal'
,
ex
finally
:
finally
:
sig
.
cancel
()
sig
.
cancel
()
# pylint:disable=no-member
@
greentest
.
skipIf
((
greentest
.
PY3
@
greentest
.
skipIf
((
greentest
.
PY3
...
...
src/gevent/tests/test__socket.py
View file @
f5da156b
...
@@ -320,7 +320,7 @@ class TestTCP(greentest.TestCase):
...
@@ -320,7 +320,7 @@ class TestTCP(greentest.TestCase):
# Issue 944
# Issue 944
# If we have SOCK_CLOEXEC or similar, we shouldn't be passing
# If we have SOCK_CLOEXEC or similar, we shouldn't be passing
# them through to the getaddrinfo call that connect() makes
# them through to the getaddrinfo call that connect() makes
SOCK_CLOEXEC
=
socket
.
SOCK_CLOEXEC
SOCK_CLOEXEC
=
socket
.
SOCK_CLOEXEC
# pylint:disable=no-member
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
|
SOCK_CLOEXEC
)
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
|
SOCK_CLOEXEC
)
def
accept_once
():
def
accept_once
():
...
@@ -421,7 +421,7 @@ class TestFunctions(greentest.TestCase):
...
@@ -421,7 +421,7 @@ class TestFunctions(greentest.TestCase):
gevent
.
sleep
(
10
)
gevent
.
sleep
(
10
)
with
self
.
assertRaises
(
gevent
.
socket
.
timeout
):
with
self
.
assertRaises
(
gevent
.
socket
.
timeout
):
gevent
.
socket
.
wait
(
io
(),
timeout
=
0.01
)
gevent
.
socket
.
wait
(
io
(),
timeout
=
0.01
)
# pylint:disable=no-member
def
test_signatures
(
self
):
def
test_signatures
(
self
):
...
...
src/gevent/tests/test__socket_dns.py
View file @
f5da156b
#!/usr/bin/python
#!/usr/bin/python
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# pylint:disable=broad-except
import
gevent
import
gevent
from
gevent
import
monkey
from
gevent
import
monkey
...
@@ -83,9 +83,9 @@ def run(function, *args):
...
@@ -83,9 +83,9 @@ def run(function, *args):
return
result
,
delta
return
result
,
delta
def
log_call
(
result
,
time
,
function
,
*
args
):
def
log_call
(
result
,
run
time
,
function
,
*
args
):
log
(
format_call
(
function
,
args
))
log
(
format_call
(
function
,
args
))
log_fresult
(
result
,
time
)
log_fresult
(
result
,
run
time
)
def
compare_relaxed
(
a
,
b
):
def
compare_relaxed
(
a
,
b
):
...
@@ -332,9 +332,11 @@ class TestCase(greentest.TestCase):
...
@@ -332,9 +332,11 @@ class TestCase(greentest.TestCase):
# If we're using the ares resolver, allow the real resolver to generate an
# If we're using the ares resolver, allow the real resolver to generate an
# error that the ares resolver actually gets an answer to.
# error that the ares resolver actually gets an answer to.
if
(
RESOLVER_NOT_SYSTEM
if
(
and
isinstance
(
real_result
,
errors
)
RESOLVER_NOT_SYSTEM
and
not
isinstance
(
gevent_result
,
errors
)):
and
isinstance
(
real_result
,
errors
)
and
not
isinstance
(
gevent_result
,
errors
)
):
return
return
# From 2.7 on, assertEqual does a better job highlighting the results than we would
# From 2.7 on, assertEqual does a better job highlighting the results than we would
...
@@ -453,7 +455,7 @@ class SanitizedHostsFile(HostsFile):
...
@@ -453,7 +455,7 @@ class SanitizedHostsFile(HostsFile):
# the system's etc hosts?
# the system's etc hosts?
class
TestEtcHosts
(
TestCase
):
class
TestEtcHosts
(
TestCase
):
MAX_HOSTS
=
os
.
getenv
(
'GEVENTTEST_MAX_ETC_HOSTS'
,
10
)
MAX_HOSTS
=
int
(
os
.
getenv
(
'GEVENTTEST_MAX_ETC_HOSTS'
,
'10'
)
)
@
classmethod
@
classmethod
def
populate_tests
(
cls
):
def
populate_tests
(
cls
):
...
@@ -493,7 +495,7 @@ class TestFamily(TestCase):
...
@@ -493,7 +495,7 @@ class TestFamily(TestCase):
cls
.
_result
=
getattr
(
socket
,
'getaddrinfo'
)(
TestGeventOrg
.
HOSTNAME
,
None
)
cls
.
_result
=
getattr
(
socket
,
'getaddrinfo'
)(
TestGeventOrg
.
HOSTNAME
,
None
)
return
cls
.
_result
return
cls
.
_result
def
assert_error
(
self
,
error
,
function
,
*
args
):
def
assert_error
(
self
,
error
,
function
,
*
args
):
# pylint:disable=arguments-differ
try
:
try
:
result
=
function
(
*
args
)
result
=
function
(
*
args
)
raise
AssertionError
(
'%s: Expected to raise %s, instead returned %r'
%
(
function
,
error
,
result
))
raise
AssertionError
(
'%s: Expected to raise %s, instead returned %r'
%
(
function
,
error
,
result
))
...
...
src/gevent/tests/test__socket_ssl.py
View file @
f5da156b
#!/usr/bin/python
#!/usr/bin/python
from
gevent
import
monkey
;
monkey
.
patch_all
()
from
gevent
import
monkey
import
sys
monkey
.
patch_all
()
import
gevent.testing
as
greentest
import
unittest
try
:
try
:
import
httplib
import
httplib
except
ImportError
:
except
ImportError
:
from
http
import
client
as
httplib
from
http
import
client
as
httplib
import
socket
import
socket
if
not
hasattr
(
socket
,
'ssl'
):
sys
.
exit
(
0
)
import
gevent.testing
as
greentest
@
unittest
.
skipUnless
(
hasattr
(
socket
,
'ssl'
),
"Needs socket.ssl"
)
class
AmazonHTTPSTests
(
greentest
.
TestCase
):
class
AmazonHTTPSTests
(
greentest
.
TestCase
):
__timeout__
=
30
__timeout__
=
30
...
@@ -25,7 +30,7 @@ class AmazonHTTPSTests(greentest.TestCase):
...
@@ -25,7 +30,7 @@ class AmazonHTTPSTests(greentest.TestCase):
def
test_str_and_repr
(
self
):
def
test_str_and_repr
(
self
):
conn
=
socket
.
socket
()
conn
=
socket
.
socket
()
conn
.
connect
((
'sdb.amazonaws.com'
,
443
))
conn
.
connect
((
'sdb.amazonaws.com'
,
443
))
ssl_conn
=
socket
.
ssl
(
conn
)
ssl_conn
=
socket
.
ssl
(
conn
)
# pylint:disable=no-member
assert
str
(
ssl_conn
)
assert
str
(
ssl_conn
)
assert
repr
(
ssl_conn
)
assert
repr
(
ssl_conn
)
...
...
src/gevent/tests/test__ssl.py
View file @
f5da156b
...
@@ -28,7 +28,7 @@ class TestSSL(test__socket.TestTCP):
...
@@ -28,7 +28,7 @@ class TestSSL(test__socket.TestTCP):
self
.
_close_on_teardown
(
raw_listener
)
self
.
_close_on_teardown
(
raw_listener
)
return
listener
return
listener
def
create_connection
(
self
,
*
args
,
**
kwargs
):
def
create_connection
(
self
,
*
args
,
**
kwargs
):
# pylint:disable=arguments-differ
return
ssl
.
wrap_socket
(
super
(
TestSSL
,
self
).
create_connection
(
*
args
,
**
kwargs
))
return
ssl
.
wrap_socket
(
super
(
TestSSL
,
self
).
create_connection
(
*
args
,
**
kwargs
))
# The SSL library can take a long time to buffer the large amount of data we're trying
# The SSL library can take a long time to buffer the large amount of data we're trying
...
...
src/gevent/tests/test__subprocess.py
View file @
f5da156b
...
@@ -222,7 +222,7 @@ class Test(greentest.TestCase):
...
@@ -222,7 +222,7 @@ class Test(greentest.TestCase):
def
test_check_output_keyword_error
(
self
):
def
test_check_output_keyword_error
(
self
):
try
:
try
:
subprocess
.
check_output
([
sys
.
executable
,
'-c'
,
'import sys; sys.exit(44)'
])
subprocess
.
check_output
([
sys
.
executable
,
'-c'
,
'import sys; sys.exit(44)'
])
except
subprocess
.
CalledProcessError
as
e
:
except
subprocess
.
CalledProcessError
as
e
:
# pylint:disable=no-member
self
.
assertEqual
(
e
.
returncode
,
44
)
self
.
assertEqual
(
e
.
returncode
,
44
)
else
:
else
:
raise
AssertionError
(
'must fail with CalledProcessError'
)
raise
AssertionError
(
'must fail with CalledProcessError'
)
...
@@ -282,7 +282,6 @@ class Test(greentest.TestCase):
...
@@ -282,7 +282,6 @@ class Test(greentest.TestCase):
# If the file is in universal_newlines mode, we should always get a str when
# If the file is in universal_newlines mode, we should always get a str when
# there is no output.
# there is no output.
# https://github.com/gevent/gevent/pull/939
# https://github.com/gevent/gevent/pull/939
kwargs
=
{
'universal_newlines'
:
True
}
self
.
__test_no_output
({
'universal_newlines'
:
True
},
str
)
self
.
__test_no_output
({
'universal_newlines'
:
True
},
str
)
@
greentest
.
skipIf
(
sys
.
version_info
[:
2
]
<
(
3
,
6
),
"Need encoding argument"
)
@
greentest
.
skipIf
(
sys
.
version_info
[:
2
]
<
(
3
,
6
),
"Need encoding argument"
)
...
@@ -397,11 +396,11 @@ class RunFuncTestCase(greentest.TestCase):
...
@@ -397,11 +396,11 @@ class RunFuncTestCase(greentest.TestCase):
# call() function with sequence argument
# call() function with sequence argument
cp
=
self
.
run_python
(
"import sys; sys.exit(47)"
)
cp
=
self
.
run_python
(
"import sys; sys.exit(47)"
)
self
.
assertEqual
(
cp
.
returncode
,
47
)
self
.
assertEqual
(
cp
.
returncode
,
47
)
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
):
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
):
# pylint:disable=no-member
cp
.
check_returncode
()
cp
.
check_returncode
()
def
test_check
(
self
):
def
test_check
(
self
):
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
)
as
c
:
with
self
.
assertRaises
(
subprocess
.
CalledProcessError
)
as
c
:
# pylint:disable=no-member
self
.
run_python
(
"import sys; sys.exit(47)"
,
check
=
True
)
self
.
run_python
(
"import sys; sys.exit(47)"
,
check
=
True
)
self
.
assertEqual
(
c
.
exception
.
returncode
,
47
)
self
.
assertEqual
(
c
.
exception
.
returncode
,
47
)
...
...
src/gevent/tests/test__threading_monkey_in_thread.py
View file @
f5da156b
...
@@ -35,7 +35,7 @@ class Test(greentest.TestCase):
...
@@ -35,7 +35,7 @@ class Test(greentest.TestCase):
thread
.
start
()
thread
.
start
()
try
:
try
:
thread
.
join
()
thread
.
join
()
except
:
except
:
# pylint:disable=bare-except
# XXX: This can raise LoopExit in some cases.
# XXX: This can raise LoopExit in some cases.
greentest
.
reraiseFlakyTestRaceCondition
()
greentest
.
reraiseFlakyTestRaceCondition
()
...
...
src/gevent/tests/test__threading_patched_local.py
View file @
f5da156b
from
gevent
import
monkey
;
monkey
.
patch_all
()
from
gevent
import
monkey
;
monkey
.
patch_all
()
import
threading
import
threading
localdata
=
threading
.
local
()
localdata
=
threading
.
local
()
localdata
.
x
=
"hello"
localdata
.
x
=
"hello"
assert
localdata
.
x
==
'hello'
assert
localdata
.
x
==
'hello'
...
@@ -9,7 +10,7 @@ success = []
...
@@ -9,7 +10,7 @@ success = []
def
func
():
def
func
():
try
:
try
:
localdata
.
x
getattr
(
localdata
,
'x'
)
raise
AssertionError
(
'localdata.x must raise AttributeError'
)
raise
AssertionError
(
'localdata.x must raise AttributeError'
)
except
AttributeError
:
except
AttributeError
:
pass
pass
...
...
src/gevent/tests/test__timeout.py
View file @
f5da156b
...
@@ -89,7 +89,7 @@ class Test(greentest.TestCase):
...
@@ -89,7 +89,7 @@ class Test(greentest.TestCase):
except
TypeError
as
ex
:
except
TypeError
as
ex
:
self
.
assertTrue
(
greentest
.
PY3
,
"Py3 raises a TypeError for non-BaseExceptions"
)
self
.
assertTrue
(
greentest
.
PY3
,
"Py3 raises a TypeError for non-BaseExceptions"
)
self
.
assert_type_err
(
ex
)
self
.
assert_type_err
(
ex
)
except
:
except
:
# pylint:disable=bare-except
self
.
assertTrue
(
greentest
.
PY2
,
"Old style classes can only be raised on Py2"
)
self
.
assertTrue
(
greentest
.
PY2
,
"Old style classes can only be raised on Py2"
)
t
=
sys
.
exc_info
()[
0
]
t
=
sys
.
exc_info
()[
0
]
self
.
assertEqual
(
t
,
OldStyle
)
self
.
assertEqual
(
t
,
OldStyle
)
...
@@ -103,7 +103,7 @@ class Test(greentest.TestCase):
...
@@ -103,7 +103,7 @@ class Test(greentest.TestCase):
except
TypeError
as
ex
:
except
TypeError
as
ex
:
self
.
assertTrue
(
greentest
.
PY3
,
"Py3 raises a TypeError for non-BaseExceptions"
)
self
.
assertTrue
(
greentest
.
PY3
,
"Py3 raises a TypeError for non-BaseExceptions"
)
self
.
assert_type_err
(
ex
)
self
.
assert_type_err
(
ex
)
except
:
except
:
# pylint:disable=bare-except
self
.
assertTrue
(
greentest
.
PY2
,
"Old style classes can only be raised on Py2"
)
self
.
assertTrue
(
greentest
.
PY2
,
"Old style classes can only be raised on Py2"
)
t
=
sys
.
exc_info
()[
0
]
t
=
sys
.
exc_info
()[
0
]
self
.
assertEqual
(
t
,
OldStyle
)
self
.
assertEqual
(
t
,
OldStyle
)
...
...
src/gevent/tests/test_threading_2.py
View file @
f5da156b
...
@@ -231,6 +231,9 @@ class ThreadTests(unittest.TestCase):
...
@@ -231,6 +231,9 @@ class ThreadTests(unittest.TestCase):
worker_saw_exception
=
threading
.
Event
()
worker_saw_exception
=
threading
.
Event
()
class
Worker
(
threading
.
Thread
):
class
Worker
(
threading
.
Thread
):
id
=
None
finished
=
False
def
run
(
self
):
def
run
(
self
):
self
.
id
=
thread
.
get_ident
()
self
.
id
=
thread
.
get_ident
()
self
.
finished
=
False
self
.
finished
=
False
...
@@ -278,7 +281,7 @@ class ThreadTests(unittest.TestCase):
...
@@ -278,7 +281,7 @@ class ThreadTests(unittest.TestCase):
def
test_limbo_cleanup
(
self
):
def
test_limbo_cleanup
(
self
):
# Issue 7481: Failure to start thread should cleanup the limbo map.
# Issue 7481: Failure to start thread should cleanup the limbo map.
def
fail_new_thread
(
*
args
):
def
fail_new_thread
(
*
_
args
):
raise
thread
.
error
()
raise
thread
.
error
()
_start_new_thread
=
threading
.
_start_new_thread
_start_new_thread
=
threading
.
_start_new_thread
threading
.
_start_new_thread
=
fail_new_thread
threading
.
_start_new_thread
=
fail_new_thread
...
@@ -406,7 +409,7 @@ class ThreadTests(unittest.TestCase):
...
@@ -406,7 +409,7 @@ class ThreadTests(unittest.TestCase):
kwargs
=
{
'yet_another'
:
self
})
kwargs
=
{
'yet_another'
:
self
})
self
.
thread
.
start
()
self
.
thread
.
start
()
def
_run
(
self
,
other_ref
,
yet_another
):
def
_run
(
self
,
_other_ref
,
_
yet_another
):
if
self
.
should_raise
:
if
self
.
should_raise
:
raise
SystemExit
raise
SystemExit
...
@@ -542,23 +545,24 @@ class ThreadJoinOnShutdown(unittest.TestCase):
...
@@ -542,23 +545,24 @@ class ThreadJoinOnShutdown(unittest.TestCase):
class
ThreadingExceptionTests
(
unittest
.
TestCase
):
class
ThreadingExceptionTests
(
unittest
.
TestCase
):
# A RuntimeError should be raised if Thread.start() is called
# A RuntimeError should be raised if Thread.start() is called
# multiple times.
# multiple times.
# pylint:disable=bad-thread-instantiation
def
test_start_thread_again
(
self
):
def
test_start_thread_again
(
self
):
thread
=
threading
.
Thread
()
thread
_
=
threading
.
Thread
()
thread
.
start
()
thread
_
.
start
()
self
.
assertRaises
(
RuntimeError
,
thread
.
start
)
self
.
assertRaises
(
RuntimeError
,
thread
_
.
start
)
def
test_joining_current_thread
(
self
):
def
test_joining_current_thread
(
self
):
current_thread
=
threading
.
current_thread
()
current_thread
=
threading
.
current_thread
()
self
.
assertRaises
(
RuntimeError
,
current_thread
.
join
)
self
.
assertRaises
(
RuntimeError
,
current_thread
.
join
)
def
test_joining_inactive_thread
(
self
):
def
test_joining_inactive_thread
(
self
):
thread
=
threading
.
Thread
()
thread
_
=
threading
.
Thread
()
self
.
assertRaises
(
RuntimeError
,
thread
.
join
)
self
.
assertRaises
(
RuntimeError
,
thread
_
.
join
)
def
test_daemonize_active_thread
(
self
):
def
test_daemonize_active_thread
(
self
):
thread
=
threading
.
Thread
()
thread
_
=
threading
.
Thread
()
thread
.
start
()
thread
_
.
start
()
self
.
assertRaises
(
RuntimeError
,
setattr
,
thread
,
"daemon"
,
True
)
self
.
assertRaises
(
RuntimeError
,
setattr
,
thread
_
,
"daemon"
,
True
)
class
LockTests
(
lock_tests
.
LockTests
):
class
LockTests
(
lock_tests
.
LockTests
):
...
...
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