Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 86b09cc

Browse files
committed
last stubbed method prevails.
1 parent ce7a549 commit 86b09cc

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

doublex/internal.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ class OperationList(list):
5858
def lookup(self, invocation):
5959
if not invocation in self:
6060
raise LookupError
61-
return filter(lambda i: i == invocation, self)[-1]
61+
62+
return [i for i in self if i == invocation][-1]
6263

6364
def show(self, indent=0):
6465
if not self:

doublex/test/unit_tests.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,21 @@ def test_keyworked_or_positional_are_equivalent(self):
174174
assert_that(self.stub.kwarg_method(6), is_(6000))
175175
assert_that(self.stub.kwarg_method(key_param=6), is_(6000))
176176

177-
def test_uses_the_last_configuration_of_a_method_that_has_been_previously_stubbed(self):
177+
def test_last_stubbed_method_prevails(self):
178178
with self.stub:
179179
self.stub.hello().returns("hi!")
180180

181181
with self.stub:
182-
self.stub.hello().returns("Hello!")
182+
self.stub.hello().returns("bye!")
183183

184-
assert_that(self.stub.hello(), is_("Hello!"))
184+
assert_that(self.stub.hello(), is_("bye!"))
185+
186+
def test_last_stubbed_method_prevails_same_with(self):
187+
with self.stub:
188+
self.stub.hello().returns("hi!")
189+
self.stub.hello().returns("bye!")
190+
191+
assert_that(self.stub.hello(), is_("bye!"))
185192

186193
def test_returning_tuple(self):
187194
with self.stub:

0 commit comments

Comments
 (0)