[pypy-commit] pypy default: Add a test for operator.methodcaller()
arigo
noreply at buildbot.pypy.org
Fri Jul 24 12:32:10 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r78653:e7ee41dab3bd
Date: 2015-07-24 12:31 +0200
http://bitbucket.org/pypy/pypy/changeset/e7ee41dab3bd/
Log: Add a test for operator.methodcaller()
diff --git a/pypy/module/operator/test/test_operator.py b/pypy/module/operator/test/test_operator.py
--- a/pypy/module/operator/test/test_operator.py
+++ b/pypy/module/operator/test/test_operator.py
@@ -10,13 +10,16 @@
class A(object):
getx = operator.attrgetter('x')
get3 = operator.itemgetter(3)
+ callx = operator.methodcaller("append", "x")
a = A()
a.x = 5
assert a.getx(a) == 5
assert a.get3("foobar") == "b"
assert a.getx(*(a,)) == 5
assert a.get3(obj="foobar") == "b"
-
+ l = []
+ a.callx(l)
+ assert l == ["x"]
def test_getter_multiple_gest(self):
import operator
More information about the pypy-commit
mailing list