diff --git a/src/wrappers.py b/src/wrappers.py index 125f507..e48ed9b 100644 --- a/src/wrappers.py +++ b/src/wrappers.py @@ -178,10 +178,10 @@ class ObjectProxy(six.with_metaclass(_ObjectProxyMetaType)): return self.__wrapped__ * other def __div__(self, other): - return operator.__div__(self.__wrapped__, other) + return operator.div(self.__wrapped__, other) def __truediv__(self, other): - return operator.__truediv__(self.__wrapped__, other) + return operator.truediv(self.__wrapped__, other) def __floordiv__(self, other): return self.__wrapped__ // other @@ -220,10 +220,10 @@ class ObjectProxy(six.with_metaclass(_ObjectProxyMetaType)): return other * self.__wrapped__ def __rdiv__(self, other): - return operator.__div__(other, self.__wrapped__) + return operator.div(other, self.__wrapped__) def __rtruediv__(self, other): - return operator.__truediv__(other, self.__wrapped__) + return operator.truediv(other, self.__wrapped__) def __rfloordiv__(self, other): return other // self.__wrapped__ @@ -265,11 +265,11 @@ class ObjectProxy(six.with_metaclass(_ObjectProxyMetaType)): return self def __idiv__(self, other): - self.__wrapped__ = operator.__idiv__(self.__wrapped__, other) + self.__wrapped__ = operator.idiv(self.__wrapped__, other) return self def __itruediv__(self, other): - self.__wrapped__ = operator.__itruediv__(self.__wrapped__, other) + self.__wrapped__ = operator.itruediv(self.__wrapped__, other) return self def __ifloordiv__(self, other): @@ -332,7 +332,7 @@ class ObjectProxy(six.with_metaclass(_ObjectProxyMetaType)): return hex(self.__wrapped__) def __index__(self): - return operator.__index__(self.__wrapped__) + return operator.index(self.__wrapped__) def __len__(self): return len(self.__wrapped__) diff --git a/tests/test_object_proxy.py b/tests/test_object_proxy.py index ca4c900..99f1a91 100644 --- a/tests/test_object_proxy.py +++ b/tests/test_object_proxy.py @@ -1139,12 +1139,13 @@ class TestAsNumberObjectProxy(unittest.TestCase): self.assertEqual(hex(value), hex(20)) def test_index(self): - value = wrapt.ObjectProxy(20) + class Class(object): + def __index__(self): + return 1 + value = wrapt.ObjectProxy(Class()) + items = [0, 1, 2] - # PyPy doesn't implement operator.__index__(). - - if not is_pypy: - self.assertEqual(value.__index__(), operator.__index__(20)) + self.assertEqual(items[value], items[1]) class TestAsSequenceObjectProxy(unittest.TestCase):