Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
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
TeDomum
Matrix
Commits
113342a7
Commit
113342a7
authored
10 years ago
by
Paul "LeoNerd" Evans
Browse files
Options
Downloads
Patches
Plain Diff
Ability to assert a DeferredMockCallable has received no calls
parent
b1da3fa0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/utils.py
+15
-0
15 additions, 0 deletions
tests/utils.py
with
15 additions
and
0 deletions
tests/utils.py
+
15
−
0
View file @
113342a7
...
...
@@ -248,8 +248,11 @@ class DeferredMockCallable(object):
def
__init__
(
self
):
self
.
expectations
=
[]
self
.
calls
=
[]
def
__call__
(
self
,
*
args
,
**
kwargs
):
self
.
calls
.
append
((
args
,
kwargs
))
if
not
self
.
expectations
:
raise
ValueError
(
"
%r has no pending calls to handle call(%s)
"
%
(
self
,
_format_call
(
args
,
kwargs
))
...
...
@@ -272,3 +275,15 @@ class DeferredMockCallable(object):
while
self
.
expectations
:
(
_
,
_
,
d
)
=
self
.
expectations
.
pop
(
0
)
yield
d
self
.
calls
=
[]
def
assert_had_no_calls
(
self
):
if
self
.
calls
:
calls
=
self
.
calls
self
.
calls
=
[]
raise
AssertionError
(
"
Expected not to received any calls, got:
\n
"
+
"
\n
"
.
join
([
"
call(%s)
"
%
_format_call
(
c
[
0
],
c
[
1
])
for
c
in
calls
])
)
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