From 16f4771d2442b0438e7b245662f9f66e66790d72 Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Sun, 20 Jun 2010 12:42:47 -0300 Subject: Implemented Expect helper, which allows creating a new expect() "function" with an explicitly provided Mocker instance. This helps in cases where the expression can't result in a Mock instance (e.g. expect(iter(mock))) (#196388). --- test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test.py') diff --git a/test.py b/test.py index 68f3125..dc160b3 100755 --- a/test.py +++ b/test.py @@ -25,7 +25,7 @@ from mocker import \ mock_returner_recorder, FunctionRunner, Orderer, SpecChecker, \ spec_checker_recorder, match_params, ANY, IS, CONTAINS, IN, MATCH, ARGS, \ KWARGS, MatchError, PathExecuter, ProxyReplacer, Patcher, Undefined, \ - PatchedMethod, MockerTestCase, ReplayRestoreEvent, OnRestoreCaller + PatchedMethod, MockerTestCase, ReplayRestoreEvent, OnRestoreCaller, Expect class TestCase(unittest.TestCase): @@ -272,6 +272,13 @@ class ExpectTest(TestCase): self.mocker.replay() self.assertEquals(obj.attr, 42) + def test_explicit_expect_instance(self): + obj = self.mocker.mock() + myexpect = Expect(self.mocker) + myexpect(iter(obj)).generate([1, 2, 3]).count(1, 2) + self.mocker.replay() + self.assertEquals(list(obj), [1, 2, 3]) + class MockerTestCaseTest(TestCase): -- cgit v1.2.1