diff options
Diffstat (limited to 'Lib/test/test_funcattrs.py')
-rw-r--r-- | Lib/test/test_funcattrs.py | 61 |
1 files changed, 17 insertions, 44 deletions
diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index 66ba9cb..bd9caff 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -67,13 +67,8 @@ else: raise TestFailed('expected AttributeError') # In Python 2.1 beta 1, we disallowed setting attributes on unbound methods # (it was already disallowed on bound methods). See the PEP for details. -try: - F.a.publish = 1 -except (AttributeError, TypeError): pass -else: raise TestFailed('expected AttributeError or TypeError') - -# But setting it explicitly on the underlying function object is okay. -F.a.im_func.publish = 1 +# In Python 3.0 unbound methods are gone. +F.a.publish = 1 if F.a.publish != 1: raise TestFailed('unbound method attribute not set to expected value') @@ -92,30 +87,8 @@ try: except (AttributeError, TypeError): pass else: raise TestFailed('expected AttributeError or TypeError') -# See the comment above about the change in semantics for Python 2.1b1 -try: - F.a.myclass = F -except (AttributeError, TypeError): pass -else: raise TestFailed('expected AttributeError or TypeError') - -F.a.im_func.myclass = F - -f1.a.myclass -f2.a.myclass -f1.a.myclass -F.a.myclass - -if f1.a.myclass is not f2.a.myclass or \ - f1.a.myclass is not F.a.myclass: - raise TestFailed('attributes were not the same') - # try setting __dict__ -try: - F.a.__dict__ = (1, 2, 3) -except (AttributeError, TypeError): pass -else: raise TestFailed('expected TypeError or AttributeError') - -F.a.im_func.__dict__ = {'one': 11, 'two': 22, 'three': 33} +F.a.__dict__ = {'one': 11, 'two': 22, 'three': 33} if f1.a.two != 22: raise TestFailed('setting __dict__') @@ -315,9 +288,9 @@ def test_func_dict(): def test_im_class(): class C: def foo(self): pass - verify(C.foo.im_class is C) + #verify(C.foo.im_class is C) verify(C().foo.im_class is C) - cantset(C.foo, "im_class", C) + #cantset(C.foo, "im_class", C) cantset(C().foo, "im_class", C) def test_im_func(): @@ -325,19 +298,19 @@ def test_im_func(): class C: pass C.foo = foo - verify(C.foo.im_func is foo) + #verify(C.foo.im_func is foo) verify(C().foo.im_func is foo) - cantset(C.foo, "im_func", foo) + #cantset(C.foo, "im_func", foo) cantset(C().foo, "im_func", foo) def test_im_self(): class C: def foo(self): pass - verify(C.foo.im_self is None) + #verify(C.foo.im_self is None) c = C() - verify(c.foo.im_self is c) - cantset(C.foo, "im_self", None) - cantset(c.foo, "im_self", c) + #verify(c.foo.im_self is c) + #cantset(C.foo, "im_self", None) + #cantset(c.foo, "im_self", c) def test_im_dict(): class C: @@ -345,24 +318,24 @@ def test_im_dict(): foo.bar = 42 verify(C.foo.__dict__ == {'bar': 42}) verify(C().foo.__dict__ == {'bar': 42}) - cantset(C.foo, "__dict__", C.foo.__dict__) - cantset(C().foo, "__dict__", C.foo.__dict__) + #cantset(C.foo, "__dict__", C.foo.__dict__) + #cantset(C().foo, "__dict__", C.foo.__dict__) def test_im_doc(): class C: def foo(self): "hello" verify(C.foo.__doc__ == "hello") verify(C().foo.__doc__ == "hello") - cantset(C.foo, "__doc__", "hello") - cantset(C().foo, "__doc__", "hello") + #cantset(C.foo, "__doc__", "hello") + #cantset(C().foo, "__doc__", "hello") def test_im_name(): class C: def foo(self): pass verify(C.foo.__name__ == "foo") verify(C().foo.__name__ == "foo") - cantset(C.foo, "__name__", "foo") - cantset(C().foo, "__name__", "foo") + #cantset(C.foo, "__name__", "foo") + #cantset(C().foo, "__name__", "foo") def testmore(): test_func_closure() |