From 64a3cb2446b664817329bac127da9fe91c7e54ee Mon Sep 17 00:00:00 2001 From: Dawid Fatyga Date: Tue, 24 Apr 2012 23:41:02 +0200 Subject: Added test for changed semantics in Python 3. --- mox_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mox_test.py b/mox_test.py index 3d95f38..434ae51 100755 --- a/mox_test.py +++ b/mox_test.py @@ -23,6 +23,7 @@ import io import unittest import re +import sys import mox @@ -748,6 +749,21 @@ class MockAnythingTest(unittest.TestCase): class MethodCheckerTest(unittest.TestCase): """Tests MockMethod's use of MethodChecker method.""" + def testUnboundMethodsRequiresInstance(self): + # SKIP TEST IN PYTHON 2.x (Ugly hack for python 2.6) + # REASON: semantics for unbound methods has changed only in Python 3 + # so this test in earlier versions is invald + if sys.version_info < (3, 0): + return + + instance = CheckCallTestClass() + method = mox.MockMethod('NoParameters', [], False, + CheckCallTestClass.NoParameters) + + self.assertRaises(AttributeError, method) + method(instance) + self.assertRaises(AttributeError, method, instance, 1) + def testNoParameters(self): method = mox.MockMethod('NoParameters', [], False, CheckCallTestClass.NoParameters, -- cgit v1.2.1