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):
getcurrent
().
switch_in
()
try
:
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
)
except
SystemExit
:
# raised by quit()
if
hasattr
(
sys
,
'exc_clear'
):
# py2
...
...
src/greentest/greentest.py
View file @
29e42097
...
...
@@ -117,7 +117,7 @@ class ExpectedException(Exception):
def
wrap_switch_count_check
(
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
)
self
.
switch_expected
=
getattr
(
self
,
'switch_expected'
,
True
)
if
initial_switch_count
is
not
None
:
...
...
@@ -137,7 +137,7 @@ def wrap_switch_count_check(method):
else
:
raise
AssertionError
(
'Invalid value for switch_expected: %r'
%
(
self
.
switch_expected
,
))
return
result
return
wrap
ped
return
wrap
_switch_count_check
def
wrap_timeout
(
timeout
,
method
):
...
...
@@ -145,11 +145,11 @@ def wrap_timeout(timeout, method):
return
method
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_timeout
(
self
,
*
args
,
**
kwargs
):
with
gevent
.
Timeout
(
timeout
,
'test timed out'
,
ref
=
False
):
return
method
(
self
,
*
args
,
**
kwargs
)
return
wrap
ped
return
wrap
_timeout
def
ignores_leakcheck
(
func
):
func
.
ignore_leakcheck
=
True
...
...
@@ -193,7 +193,7 @@ def wrap_refcount(method):
return
diff
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_refcount
(
self
,
*
args
,
**
kwargs
):
gc
.
collect
()
gc
.
collect
()
gc
.
collect
()
...
...
@@ -253,12 +253,12 @@ def wrap_refcount(method):
gc
.
enable
()
self
.
skipTearDown
=
True
return
wrap
ped
return
wrap
_refcount
def
wrap_error_fatal
(
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
# which is a global default to all hubs
SYSTEM_ERROR
=
gevent
.
get_hub
().
SYSTEM_ERROR
...
...
@@ -267,12 +267,12 @@ def wrap_error_fatal(method):
return
method
(
self
,
*
args
,
**
kwargs
)
finally
:
gevent
.
get_hub
().
SYSTEM_ERROR
=
SYSTEM_ERROR
return
wrap
ped
return
wrap
_error_fatal
def
wrap_restore_handle_error
(
method
):
@
wraps
(
method
)
def
wrap
ped
(
self
,
*
args
,
**
kwargs
):
def
wrap
_restore_handle_error
(
self
,
*
args
,
**
kwargs
):
old
=
gevent
.
get_hub
().
handle_error
try
:
return
method
(
self
,
*
args
,
**
kwargs
)
...
...
@@ -280,7 +280,7 @@ def wrap_restore_handle_error(method):
gevent
.
get_hub
().
handle_error
=
old
if
self
.
peek_error
()[
0
]
is
not
None
:
gevent
.
getcurrent
().
throw
(
*
self
.
peek_error
()[
1
:])
return
wrap
ped
return
wrap
_restore_handle_error
def
_get_class_attr
(
classDict
,
bases
,
attr
,
default
=
AttributeError
):
...
...
@@ -315,7 +315,7 @@ class TestCaseMetaClass(type):
timeout
*=
6
check_totalrefcount
=
_get_class_attr
(
classDict
,
bases
,
'check_totalrefcount'
,
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
):
classDict
.
pop
(
key
)
#value = wrap_switch_count_check(value)
...
...
src/greentest/test__backdoor.py
View file @
29e42097
...
...
@@ -58,6 +58,7 @@ class Test(greentest.TestCase):
def
test_quit
(
self
):
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
.
start
()
conn
=
None
try
:
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
read_until
(
conn
,
'>>> '
)
...
...
@@ -65,12 +66,14 @@ class Test(greentest.TestCase):
line
=
readline
(
conn
)
self
.
assertEqual
(
line
,
''
)
finally
:
if
conn
is
not
None
:
conn
.
close
()
server
.
stop
()
def
test_sys_exit
(
self
):
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
.
start
()
conn
=
None
try
:
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
read_until
(
conn
,
b'>>> '
)
...
...
@@ -78,6 +81,7 @@ class Test(greentest.TestCase):
line
=
readline
(
conn
)
self
.
assertEqual
(
line
,
''
)
finally
:
if
conn
is
not
None
:
conn
.
close
()
server
.
stop
()
...
...
@@ -96,6 +100,7 @@ class Test(greentest.TestCase):
def
test_builtins
(
self
):
server
=
backdoor
.
BackdoorServer
((
'127.0.0.1'
,
0
))
server
.
start
()
conn
=
None
try
:
conn
=
create_connection
((
'127.0.0.1'
,
server
.
server_port
))
read_until
(
conn
,
b'>>> '
)
...
...
@@ -103,6 +108,7 @@ class Test(greentest.TestCase):
response
=
read_until
(
conn
,
'>>> '
)
self
.
assertTrue
(
len
(
response
)
<
300
,
msg
=
"locals() unusable: %s..."
%
response
)
finally
:
if
conn
is
not
None
:
conn
.
close
()
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