Author: Matti Picus <matti.pi...@gmail.com> Branch: call-via-pyobj Changeset: r85638:d87275ed7128 Date: 2016-07-09 07:54 -0400 http://bitbucket.org/pypy/pypy/changeset/d87275ed7128/
Log: rename, expand passing test to show how subclass can affect base class's nb_multiply passes w/-A and untranslated diff --git a/pypy/module/cpyext/test/test_arraymodule.py b/pypy/module/cpyext/test/test_arraymodule.py --- a/pypy/module/cpyext/test/test_arraymodule.py +++ b/pypy/module/cpyext/test/test_arraymodule.py @@ -78,13 +78,26 @@ rra = pickle.loads(s) # rra is arr backwards #assert arr.tolist() == rra.tolist() - def test_binop_mul_impl(self): + def test_subclass(self): # check that rmul is called module = self.import_module(name='array') arr = module.array('i', [2]) res = [1, 2, 3] * arr assert res == [1, 2, 3, 1, 2, 3] + + arr = module.arraybase('i', [2]) + res = [1, 2, 3] * arr + assert res == [1, 2, 3, 1, 2, 3] + + # switch nb_multiply on Arraytype, + # switches BaseArraytpye as well since tp_as_number is a reference module.switch_multiply() + + arr = module.array('i', [2]) + res = [1, 2, 3] * arr + assert res == [2, 4, 6] + + arr = module.arraybase('i', [2]) res = [1, 2, 3] * arr assert res == [2, 4, 6] _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit