diff options
author | Gustavo Niemeyer <gustavo@niemeyer.net> | 2010-06-20 12:42:47 -0300 |
---|---|---|
committer | Gustavo Niemeyer <gustavo@niemeyer.net> | 2010-06-20 12:42:47 -0300 |
commit | 16f4771d2442b0438e7b245662f9f66e66790d72 (patch) | |
tree | 1aaf5bbac7d171090455937c0a05a42ce044e414 /test.py | |
parent | 64f6cb84d6512b7c0a216699a24df73c73a75418 (diff) | |
download | mocker-16f4771d2442b0438e7b245662f9f66e66790d72.tar.gz |
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).
Diffstat (limited to 'test.py')
-rwxr-xr-x | test.py | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -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): |