Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
fuchsia.googlesource.com-third_party-python-testing-cabal-mock
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fuchsia-mirror
fuchsia.googlesource.com-third_party-python-testing-cabal-mock
Commits
7f655374
Commit
7f655374
authored
14 years ago
by
fuzzyman
Browse files
Options
Downloads
Patches
Plain Diff
Fix issue with _mock_ as varargs or varkwargs and mocksignature
parent
0a9900e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mock.py
+4
-0
4 additions, 0 deletions
mock.py
tests/testmocksignature.py
+10
-0
10 additions, 0 deletions
tests/testmocksignature.py
with
14 additions
and
0 deletions
mock.py
+
4
−
0
View file @
7f655374
...
...
@@ -86,6 +86,10 @@ def _getsignature(func, skipfirst):
regargs
=
regargs
[
1
:]
assert
'
_mock_
'
not
in
regargs
,
(
"
_mock_ is a reserved argument name, can
'
t mock signatures using _mock_
"
)
if
varargs
is
not
None
:
assert
'
_mock_
'
not
in
varargs
,
(
"
_mock_ is a reserved argument name, can
'
t mock signatures using _mock_
"
)
if
varkwargs
:
assert
'
_mock_
'
not
in
varkwargs
,
(
"
_mock_ is a reserved argument name, can
'
t mock signatures using _mock_
"
)
if
skipfirst
:
regargs
=
regargs
[
1
:]
signature
=
inspect
.
formatargspec
(
regargs
,
varargs
,
varkwargs
,
defaults
,
formatvalue
=
lambda
value
:
""
)
...
...
This diff is collapsed.
Click to expand it.
tests/testmocksignature.py
+
10
−
0
View file @
7f655374
...
...
@@ -149,5 +149,15 @@ class TestMockSignature(unittest2.TestCase):
def
f
(
_mock_
=
None
):
pass
self
.
assertRaises
(
AssertionError
,
lambda
:
mocksignature
(
f
))
def
f
(
*
_mock_
):
pass
self
.
assertRaises
(
AssertionError
,
lambda
:
mocksignature
(
f
))
def
f
(
**
_mock_
):
pass
self
.
assertRaises
(
AssertionError
,
lambda
:
mocksignature
(
f
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment