Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
d7c65e28
Commit
d7c65e28
authored
Mar 14, 2012
by
Michael Foord
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed XXX from unittest.mock docstring and switch to a nicer try...except...finally
parent
30162be9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
24 deletions
+19
-24
Lib/unittest/mock.py
Lib/unittest/mock.py
+19
-24
No files found.
Lib/unittest/mock.py
View file @
d7c65e28
...
...
@@ -619,9 +619,7 @@ class NonCallableMock(Base):
def
__dir__
(
self
):
"""Filter the output of `dir(mock)` to only useful members.
XXXX
"""
"""Filter the output of `dir(mock)` to only useful members."""
extras
=
self
.
_mock_methods
or
[]
from_type
=
dir
(
type
(
self
))
from_dict
=
list
(
self
.
__dict__
)
...
...
@@ -1057,31 +1055,28 @@ class _patch(object):
@
wraps
(
func
)
def
patched
(
*
args
,
**
keywargs
):
# could use with statement here
extra_args
=
[]
entered_patchers
=
[]
# could use try..except...finally here
try
:
try
:
for
patching
in
patched
.
patchings
:
arg
=
patching
.
__enter__
()
entered_patchers
.
append
(
patching
)
if
patching
.
attribute_name
is
not
None
:
keywargs
.
update
(
arg
)
elif
patching
.
new
is
DEFAULT
:
extra_args
.
append
(
arg
)
args
+=
tuple
(
extra_args
)
return
func
(
*
args
,
**
keywargs
)
except
:
if
(
patching
not
in
entered_patchers
and
_is_started
(
patching
)):
# the patcher may have been started, but an exception
# raised whilst entering one of its additional_patchers
entered_patchers
.
append
(
patching
)
# re-raise the exception
raise
for
patching
in
patched
.
patchings
:
arg
=
patching
.
__enter__
()
entered_patchers
.
append
(
patching
)
if
patching
.
attribute_name
is
not
None
:
keywargs
.
update
(
arg
)
elif
patching
.
new
is
DEFAULT
:
extra_args
.
append
(
arg
)
args
+=
tuple
(
extra_args
)
return
func
(
*
args
,
**
keywargs
)
except
:
if
(
patching
not
in
entered_patchers
and
_is_started
(
patching
)):
# the patcher may have been started, but an exception
# raised whilst entering one of its additional_patchers
entered_patchers
.
append
(
patching
)
# re-raise the exception
raise
finally
:
for
patching
in
reversed
(
entered_patchers
):
patching
.
__exit__
()
...
...
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