summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2002-03-28 15:49:54 (GMT)
committerFred Drake <fdrake@acm.org>2002-03-28 15:49:54 (GMT)
commitf841aa6fc0024a6c94e4e507ec943b13cbec17cc (patch)
tree8cf687b8a4993ca2513c55fd0e18746b87548505 /Lib
parent4157ffbb96865c38facfceb2456dbd8b101d1e62 (diff)
downloadcpython-f841aa6fc0024a6c94e4e507ec943b13cbec17cc.zip
cpython-f841aa6fc0024a6c94e4e507ec943b13cbec17cc.tar.gz
cpython-f841aa6fc0024a6c94e4e507ec943b13cbec17cc.tar.bz2
Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_descr.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 830cd08..f52edb6 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -1214,6 +1214,20 @@ def classmethods():
vereq(ff.__get__(0, int)(42), (int, 42))
vereq(ff.__get__(0)(42), (int, 42))
+def classmethods_in_c():
+ if verbose: print "Testing C-based class methods..."
+ import xxsubtype as spam
+ a = (1, 2, 3)
+ d = {'abc': 123}
+ x, a1, d1 = spam.spamlist.classmeth(*a, **d)
+ veris(x, None)
+ vereq((spam.spamlist,) + a, a1)
+ vereq(d, d1)
+ x, a1, d1 = spam.spamlist().classmeth(*a, **d)
+ veris(x, None)
+ vereq((spam.spamlist,) + a, a1)
+ vereq(d, d1)
+
def staticmethods():
if verbose: print "Testing static methods..."
class C(object):
@@ -1231,6 +1245,20 @@ def staticmethods():
vereq(d.foo(1), (d, 1))
vereq(D.foo(d, 1), (d, 1))
+def staticmethods_in_c():
+ if verbose: print "Testing C-based static methods..."
+ import xxsubtype as spam
+ a = (1, 2, 3)
+ d = {"abc": 123}
+ x, a1, d1 = spam.spamlist.staticmeth(*a, **d)
+ veris(x, None)
+ vereq(a, a1)
+ vereq(d, d1)
+ x, a1, d2 = spam.spamlist().staticmeth(*a, **d)
+ veris(x, None)
+ vereq(a, a1)
+ vereq(d, d1)
+
def classic():
if verbose: print "Testing classic classes..."
class C:
@@ -2884,7 +2912,9 @@ def test_main():
dynamics()
errors()
classmethods()
+ classmethods_in_c()
staticmethods()
+ staticmethods_in_c()
classic()
compattr()
newslot()