From a902346fb27f6e70fe778a8eb3a8adc2145dee08 Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Tue, 4 Dec 2007 23:56:34 -0200 Subject: Now when a spec is provided (or with proxy/replace/patch) the existence of the real method is checked even if the mocked method doesn't have to execute (e.g. due to count(0)). --- test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test.py') diff --git a/test.py b/test.py index a1810fd..92fb8a3 100755 --- a/test.py +++ b/test.py @@ -217,6 +217,15 @@ class IntegrationTest(TestCase): mock.method(1, 2) self.assertRaises(AssertionError, mock.method, 1) + def test_patch_with_spec_and_unexistent(self): + class C(object): + pass + mock = self.mocker.patch(C) + mock.method(1, 2) + self.mocker.count(0) + self.mocker.replay() + self.assertRaises(AssertionError, self.mocker.verify) + def test_mock_iter(self): """ list() uses len() as a hint. When we mock iter(), it shouldn't @@ -3146,6 +3155,15 @@ class SpecCheckerTest(TestCase): else: self.fail("AssertionError not raised") + def test_verify_unexistent_method(self): + task = SpecChecker(None) + try: + task.verify() + except AssertionError, e: + self.assertEquals(str(e), "Method not found in real specification") + else: + self.fail("AssertionError not raised") + def test_unsupported_object_for_getargspec(self): from zlib import adler32 # If that fails, this test has to change because either adler32 has -- cgit v1.2.1