Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
75e245fe
Commit
75e245fe
authored
Jan 18, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply a workaround for inspect.getmembers recent behaviour change.
parent
6959fbe6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
0 deletions
+25
-0
neo/tests/__init__.py
neo/tests/__init__.py
+25
-0
No files found.
neo/tests/__init__.py
View file @
75e245fe
...
@@ -527,3 +527,28 @@ class DoNothingConnector(Mock):
...
@@ -527,3 +527,28 @@ class DoNothingConnector(Mock):
__builtin__
.
pdb
=
lambda
depth
=
0
:
\
__builtin__
.
pdb
=
lambda
depth
=
0
:
\
debug
.
getPdb
().
set_trace
(
sys
.
_getframe
(
depth
+
1
))
debug
.
getPdb
().
set_trace
(
sys
.
_getframe
(
depth
+
1
))
def
_fixMockForInspect
():
"""
inspect module change broke Mock, see http://bugs.python.org/issue1785
Monkey-patch Mock class if needed by replacing predicate parameter on 2nd
getmembers call with isroutine (was ismethod).
"""
import
inspect
class
A
(
object
):
def
f
(
self
):
pass
if
not
inspect
.
getmembers
(
A
,
inspect
.
ismethod
):
# _setupSubclassMethodInterceptors is under the FreeBSD license.
# See pyMock module for the whole license.
def
_setupSubclassMethodInterceptors
(
self
):
methods
=
inspect
.
getmembers
(
self
.
__class__
,
inspect
.
isroutine
)
baseMethods
=
dict
(
inspect
.
getmembers
(
Mock
,
inspect
.
isroutine
))
for
m
in
methods
:
name
=
m
[
0
]
# Don't record calls to methods of Mock base class.
if
not
name
in
baseMethods
:
self
.
__dict__
[
name
]
=
MockCallable
(
name
,
self
,
handcrafted
=
True
)
from
mock
import
Mock
Mock
.
_setupSubclassMethodInterceptors
=
_setupSubclassMethodInterceptors
_fixMockForInspect
()
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