[Python-checkins] python/dist/src/Lib/test test_descr.py,1.180,1.181

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
2003年2月11日 10:44:51 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv20746/Lib/test
Modified Files:
	test_descr.py 
Log Message:
Put proper tests in classmethod_get(). Remove the type argument to
descr_check(); it wasn't useful. Change the type argument of the
various _get() methods to PyObject * because the call signature of
tp_descr_get doesn't guarantee its type.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.180
retrieving revision 1.181
diff -C2 -d -r1.180 -r1.181
*** test_descr.py	10 Feb 2003 21:31:26 -0000	1.180
--- test_descr.py	11 Feb 2003 18:44:42 -0000	1.181
***************
*** 3734,3737 ****
--- 3734,3776 ----
 veris(type(C.__dict__), type(B.__dict__))
 
+ def meth_class_get():
+ # Full coverage of descrobject.c::classmethod_get()
+ if verbose: print "Testing __get__ method of METH_CLASS C methods..."
+ # Baseline
+ arg = [1, 2, 3]
+ res = {1: None, 2: None, 3: None}
+ vereq(dict.fromkeys(arg), res)
+ vereq({}.fromkeys(arg), res)
+ # Now get the descriptor
+ descr = dict.__dict__["fromkeys"]
+ # More baseline using the descriptor directly
+ vereq(descr.__get__(None, dict)(arg), res)
+ vereq(descr.__get__({})(arg), res)
+ # Now check various error cases
+ try:
+ descr.__get__(None, None)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "shouldn't have allowed descr.__get__(None, None)"
+ try:
+ descr.__get__(42)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "shouldn't have allowed descr.__get__(42)"
+ try:
+ descr.__get__(None, 42)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "shouldn't have allowed descr.__get__(None, 42)"
+ try:
+ descr.__get__(None, int)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "shouldn't have allowed descr.__get__(None, int)"
+ 
 
 def test_main():
***************
*** 3820,3823 ****
--- 3859,3863 ----
 subclass_right_op()
 dict_type_with_metaclass()
+ meth_class_get()
 
 if verbose: print "All OK"

AltStyle によって変換されたページ (->オリジナル) /