diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-05-11 18:15:40 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:15:22 -0300 |
commit | 587bac87604aadd4d7aedba2a911bfcac9671fe3 (patch) | |
tree | d47b703a57350790647875fd89f9f4709baf9fa1 /tests | |
parent | bdd992a76956f86166256649f8bb3d42ce7439a2 (diff) |
Replaced "isUserType" test for the correct "hasCppWrapper" before method calls.
Also added an unit test for infinite recursion when duck punching a
virtual method.
Reviewed by Hugo Parente <hugo.lima@openbossa.org>
Reviewed by Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/samplebinding/duck_punching_test.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/samplebinding/duck_punching_test.py b/tests/samplebinding/duck_punching_test.py index 013e36468..2870b8c47 100644 --- a/tests/samplebinding/duck_punching_test.py +++ b/tests/samplebinding/duck_punching_test.py @@ -45,6 +45,7 @@ class DuckPunchingTest(unittest.TestCase): def setUp(self): self.multiplier = 2.0 self.duck_method_called = False + self.call_counter = 0 def testMonkeyPatchOnVirtualMethod(self): '''Injects new 'virtualMethod0' on a VirtualMethods instance and makes C++ call it.''' @@ -147,6 +148,17 @@ class DuckPunchingTest(unittest.TestCase): monkey.exists = None + def testForInfiniteRecursion(self): + def myVirtualMethod0(obj, pt, val, cpx, b): + self.call_counter += 1 + return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) + vm = VirtualMethods() + vm.virtualMethod0 = types.MethodType(myVirtualMethod0, vm, VirtualMethods) + pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True + vm.virtualMethod0(pt, val, cpx, b) + self.assertEqual(self.call_counter, 1) + + if __name__ == '__main__': unittest.main() |