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
a37b958d
Commit
a37b958d
authored
Sep 16, 2014
by
Kushal Das
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Closes #21270 : We now override tuple methods in mock.call objects.
parent
a0f33759
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
0 deletions
+19
-0
Lib/unittest/mock.py
Lib/unittest/mock.py
+6
-0
Lib/unittest/test/testmock/testmock.py
Lib/unittest/test/testmock/testmock.py
+10
-0
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/unittest/mock.py
View file @
a37b958d
...
@@ -2035,6 +2035,12 @@ class _Call(tuple):
...
@@ -2035,6 +2035,12 @@ class _Call(tuple):
return
_Call
(
name
=
name
,
parent
=
self
,
from_kall
=
False
)
return
_Call
(
name
=
name
,
parent
=
self
,
from_kall
=
False
)
def
count
(
self
,
*
args
,
**
kwargs
):
return
self
.
__getattr__
(
'count'
)(
*
args
,
**
kwargs
)
def
index
(
self
,
*
args
,
**
kwargs
):
return
self
.
__getattr__
(
'index'
)(
*
args
,
**
kwargs
)
def
__repr__
(
self
):
def
__repr__
(
self
):
if
not
self
.
from_kall
:
if
not
self
.
from_kall
:
name
=
self
.
name
or
'call'
name
=
self
.
name
or
'call'
...
...
Lib/unittest/test/testmock/testmock.py
View file @
a37b958d
...
@@ -1213,6 +1213,16 @@ class MockTest(unittest.TestCase):
...
@@ -1213,6 +1213,16 @@ class MockTest(unittest.TestCase):
text = "
call
(
daddy
=
'hero'
,
name
=
'hello'
)
"
text = "
call
(
daddy
=
'hero'
,
name
=
'hello'
)
"
self.assertEqual(repr(m.hello.call_args), text)
self.assertEqual(repr(m.hello.call_args), text)
#Issue21270 overrides tuple methods for mock.call objects
def test_override_tuple_methods(self):
c = call.count()
i = call.index(132,'hello')
m = Mock()
m.count()
m.index(132,"
hello
")
self.assertEqual(m.method_calls[0], c)
self.assertEqual(m.method_calls[1], i)
def test_mock_add_spec(self):
def test_mock_add_spec(self):
class _One(object):
class _One(object):
one = 1
one = 1
...
...
Misc/NEWS
View file @
a37b958d
...
@@ -157,6 +157,9 @@ Library
...
@@ -157,6 +157,9 @@ Library
-
Issue
#
12410
:
imaplib
.
IMAP4
now
supports
the
context
management
protocol
.
-
Issue
#
12410
:
imaplib
.
IMAP4
now
supports
the
context
management
protocol
.
Original
patch
by
Tarek
Ziad
é
.
Original
patch
by
Tarek
Ziad
é
.
-
Issue
#
21270
:
We
now
override
tuple
methods
in
mock
.
call
objects
so
that
they
can
be
used
as
normal
call
attributes
.
-
Issue
#
16662
:
load_tests
()
is
now
unconditionally
run
when
it
is
present
in
-
Issue
#
16662
:
load_tests
()
is
now
unconditionally
run
when
it
is
present
in
a
package
's __init__.py. TestLoader.loadTestsFromModule() still accepts
a
package
's __init__.py. TestLoader.loadTestsFromModule() still accepts
use_load_tests, but it is deprecated and ignored. A new keyword-only
use_load_tests, but it is deprecated and ignored. A new keyword-only
...
...
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