From 1a572f6c05cc6c7aa2b58e810684525cb8b66de7 Mon Sep 17 00:00:00 2001 From: Gustavo Niemeyer Date: Sun, 20 Jun 2010 13:21:07 -0300 Subject: Unwrap bound methods on replace() and proxy(), as suggested by James Henstridge (#270782). --- test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test.py') diff --git a/test.py b/test.py index 44f9efc..21c9d63 100755 --- a/test.py +++ b/test.py @@ -210,6 +210,13 @@ class IntegrationTest(TestCase): self.assertTrue(os.path.isfile("unexistent")) self.assertFalse(os.path.isfile("unexistent")) + def test_replace_class_method(self): + empty = self.mocker.replace("Queue.Queue.empty") + expect(empty()).result(False) + self.mocker.replay() + from Queue import Queue + self.assertEquals(Queue().empty(), False) + def test_patch_with_spec(self): class C(object): def method(self, a, b): @@ -1348,6 +1355,11 @@ class MockerTest(TestCase): mock = self.mocker.replace(original, passthrough=False) self.assertEquals(mock.__mocker_passthrough__, False) + def test_replace_with_bound_method(self): + from Queue import Queue + mock = self.mocker.replace(Queue.empty) + self.assertEquals(mock.__mocker_object__, Queue.empty.im_func) + def test_add_and_get_event(self): self.mocker.add_event(41) self.assertEquals(self.mocker.add_event(42), 42) -- cgit v1.2.1