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
29e42097
Commit
29e42097
authored
Oct 10, 2016
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix test__backdoor and backdoor undor Py36.
Also stop wrapping methods over and over. Yikes.
parent
117239ff
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
15 deletions
+26
-15
src/gevent/backdoor.py
src/gevent/backdoor.py
+6
-1
src/greentest/greentest.py
src/greentest/greentest.py
+11
-11
src/greentest/test__backdoor.py
src/greentest/test__backdoor.py
+9
-3
No files found.
src/gevent/backdoor.py
View file @
29e42097
...
@@ -134,6 +134,11 @@ class BackdoorServer(StreamServer):
...
@@ -134,6 +134,11 @@ class BackdoorServer(StreamServer):
getcurrent
().
switch_in
()
getcurrent
().
switch_in
()
try
:
try
:
console
=
InteractiveConsole
(
self
.
_create_interactive_locals
())
console
=
InteractiveConsole
(
self
.
_create_interactive_locals
())
if
sys
.
version_info
[:
3
]
>=
(
3
,
6
,
0
):
# Beginning in 3.6, the console likes to print "now exiting <class>"
# but probably our socket is already closed, so this just causes problems.
console
.
interact
(
banner
=
self
.
banner
,
exitmsg
=
''
)
else
:
console
.
interact
(
banner
=
self
.
banner
)
console
.
interact
(
banner
=
self
.
banner
)
except
SystemExit
:
# raised by quit()
except
SystemExit
:
# raised by quit()
if
hasattr
(
sys
,
'exc_clear'
):
# py2
if
hasattr
(
sys
,
'exc_clear'
):
# py2
...
...
src/greentest/greentest.py
View file @
29e42097
...
@@ -117,7 +117,7 @@ class ExpectedException(Exception):
...
@@ -117,7 +117,7 @@ class ExpectedException(Exception):
def
wrap_switch_count_check
(
method
):
def
wrap_switch_count_check
(
method
):
@
wraps
(
method
)
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_switch_count_check
(
self
,
*
args
,
**
kwargs
):
initial_switch_count
=
getattr
(
_get_hub
(),
'switch_count'
,
None
)
initial_switch_count
=
getattr
(
_get_hub
(),
'switch_count'
,
None
)
self
.
switch_expected
=
getattr
(
self
,
'switch_expected'
,
True
)
self
.
switch_expected
=
getattr
(
self
,
'switch_expected'
,
True
)
if
initial_switch_count
is
not
None
:
if
initial_switch_count
is
not
None
:
...
@@ -137,7 +137,7 @@ def wrap_switch_count_check(method):
...
@@ -137,7 +137,7 @@ def wrap_switch_count_check(method):
else
:
else
:
raise
AssertionError
(
'Invalid value for switch_expected: %r'
%
(
self
.
switch_expected
,
))
raise
AssertionError
(
'Invalid value for switch_expected: %r'
%
(
self
.
switch_expected
,
))
return
result
return
result
return
wrap
ped
return
wrap
_switch_count_check
def
wrap_timeout
(
timeout
,
method
):
def
wrap_timeout
(
timeout
,
method
):
...
@@ -145,11 +145,11 @@ def wrap_timeout(timeout, method):
...
@@ -145,11 +145,11 @@ def wrap_timeout(timeout, method):
return
method
return
method
@
wraps
(
method
)
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_timeout
(
self
,
*
args
,
**
kwargs
):
with
gevent
.
Timeout
(
timeout
,
'test timed out'
,
ref
=
False
):
with
gevent
.
Timeout
(
timeout
,
'test timed out'
,
ref
=
False
):
return
method
(
self
,
*
args
,
**
kwargs
)
return
method
(
self
,
*
args
,
**
kwargs
)
return
wrap
ped
return
wrap
_timeout
def
ignores_leakcheck
(
func
):
def
ignores_leakcheck
(
func
):
func
.
ignore_leakcheck
=
True
func
.
ignore_leakcheck
=
True
...
@@ -193,7 +193,7 @@ def wrap_refcount(method):
...
@@ -193,7 +193,7 @@ def wrap_refcount(method):
return
diff
return
diff
@
wraps
(
method
)
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_refcount
(
self
,
*
args
,
**
kwargs
):
gc
.
collect
()
gc
.
collect
()
gc
.
collect
()
gc
.
collect
()
gc
.
collect
()
gc
.
collect
()
...
@@ -253,12 +253,12 @@ def wrap_refcount(method):
...
@@ -253,12 +253,12 @@ def wrap_refcount(method):
gc
.
enable
()
gc
.
enable
()
self
.
skipTearDown
=
True
self
.
skipTearDown
=
True
return
wrap
ped
return
wrap
_refcount
def
wrap_error_fatal
(
method
):
def
wrap_error_fatal
(
method
):
@
wraps
(
method
)
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_error_fatal
(
self
,
*
args
,
**
kwargs
):
# XXX should also be able to do gevent.SYSTEM_ERROR = object
# XXX should also be able to do gevent.SYSTEM_ERROR = object
# which is a global default to all hubs
# which is a global default to all hubs
SYSTEM_ERROR
=
gevent
.
get_hub
().
SYSTEM_ERROR
SYSTEM_ERROR
=
gevent
.
get_hub
().
SYSTEM_ERROR
...
@@ -267,12 +267,12 @@ def wrap_error_fatal(method):
...
@@ -267,12 +267,12 @@ def wrap_error_fatal(method):
return
method
(
self
,
*
args
,
**
kwargs
)
return
method
(
self
,
*
args
,
**
kwargs
)
finally
:
finally
:
gevent
.
get_hub
().
SYSTEM_ERROR
=
SYSTEM_ERROR
gevent
.
get_hub
().
SYSTEM_ERROR
=
SYSTEM_ERROR
return
wrap
ped
return
wrap
_error_fatal
def
wrap_restore_handle_error
(
method
):
def
wrap_restore_handle_error
(
method
):
@
wraps
(
method
)
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_restore_handle_error
(
self
,
*
args
,
**
kwargs
):
old
=
gevent
.
get_hub
().
handle_error
old
=
gevent
.
get_hub
().
handle_error
try
:
try
:
return
method
(
self
,
*
args
,
**
kwargs
)
return
method
(
self
,
*
args
,
**
kwargs
)
...
@@ -280,7 +280,7 @@ def wrap_restore_handle_error(method):
...
@@ -280,7 +280,7 @@ def wrap_restore_handle_error(method):
gevent
.
get_hub
().
handle_error
=
old
gevent
.
get_hub
().
handle_error
=
old
if
self
.
peek_error
()[
0
]
is
not
None
:
if
self
.
peek_error
()[
0
]
is
not
None
:
gevent
.
getcurrent
().
throw
(
*
self
.
peek_error
()[
1
:])
gevent
.
getcurrent
().
throw
(
*
self
.
peek_error
()[
1
:])
return
wrap
ped
return
wrap
_restore_handle_error
def
_get_class_attr
(
classDict
,
bases
,
attr
,
default
=
AttributeError
):
def
_get_class_attr
(
classDict
,
bases
,
attr
,
default
=
AttributeError
):
...
@@ -315,7 +315,7 @@ class TestCaseMetaClass(type):
...
@@ -315,7 +315,7 @@ class TestCaseMetaClass(type):
timeout
*=
6
timeout
*=
6
check_totalrefcount
=
_get_class_attr
(
classDict
,
bases
,
'check_totalrefcount'
,
True
)
check_totalrefcount
=
_get_class_attr
(
classDict
,
bases
,
'check_totalrefcount'
,
True
)
error_fatal
=
_get_class_attr
(
classDict
,
bases
,
'error_fatal'
,
True
)
error_fatal
=
_get_class_attr
(
classDict
,
bases
,
'error_fatal'
,
True
)
for
key
,
value
in
classDict
.
items
():
for
key
,
value
in
list
(
classDict
.
items
()):
# Python 3: must copy, we mutate
if
key
.
startswith
(
'test'
)
and
callable
(
value
):
if
key
.
startswith
(
'test'
)
and
callable
(
value
):
classDict
.
pop
(
key
)
classDict
.
pop
(
key
)
#value = wrap_switch_count_check(value)
#value = wrap_switch_count_check(value)
...
...
src/greentest/test__backdoor.py
View file @
29e42097
...
@@ -58,6 +58,7 @@ class Test(greentest.TestCase):
...
@@ -58,6 +58,7 @@ class Test(greentest.TestCase):
def
test_quit
(
self
):
def
test_quit
(
self
):
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
.
start
()
server
.
start
()
conn
=
None
try
:
try
:
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
read_until
(
conn
,
'>>> '
)
read_until
(
conn
,
'>>> '
)
...
@@ -65,12 +66,14 @@ class Test(greentest.TestCase):
...
@@ -65,12 +66,14 @@ class Test(greentest.TestCase):
line
=
readline
(
conn
)
line
=
readline
(
conn
)
self
.
assertEqual
(
line
,
''
)
self
.
assertEqual
(
line
,
''
)
finally
:
finally
:
if
conn
is
not
None
:
conn
.
close
()
conn
.
close
()
server
.
stop
()
server
.
stop
()
def
test_sys_exit
(
self
):
def
test_sys_exit
(
self
):
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
.
start
()
server
.
start
()
conn
=
None
try
:
try
:
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
read_until
(
conn
,
b'>>> '
)
read_until
(
conn
,
b'>>> '
)
...
@@ -78,6 +81,7 @@ class Test(greentest.TestCase):
...
@@ -78,6 +81,7 @@ class Test(greentest.TestCase):
line
=
readline
(
conn
)
line
=
readline
(
conn
)
self
.
assertEqual
(
line
,
''
)
self
.
assertEqual
(
line
,
''
)
finally
:
finally
:
if
conn
is
not
None
:
conn
.
close
()
conn
.
close
()
server
.
stop
()
server
.
stop
()
...
@@ -96,6 +100,7 @@ class Test(greentest.TestCase):
...
@@ -96,6 +100,7 @@ class Test(greentest.TestCase):
def
test_builtins
(
self
):
def
test_builtins
(
self
):
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
.
start
()
server
.
start
()
conn
=
None
try
:
try
:
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
read_until
(
conn
,
b'>>> '
)
read_until
(
conn
,
b'>>> '
)
...
@@ -103,6 +108,7 @@ class Test(greentest.TestCase):
...
@@ -103,6 +108,7 @@ class Test(greentest.TestCase):
response
=
read_until
(
conn
,
'>>> '
)
response
=
read_until
(
conn
,
'>>> '
)
self
.
assertTrue
(
len
(
response
)
<
300
,
msg
=
"locals() unusable: %s..."
%
response
)
self
.
assertTrue
(
len
(
response
)
<
300
,
msg
=
"locals() unusable: %s..."
%
response
)
finally
:
finally
:
if
conn
is
not
None
:
conn
.
close
()
conn
.
close
()
server
.
stop
()
server
.
stop
()
...
...
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