Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
test.test_funcattrs.InstancemethodAttrTest Class Reference
Inheritance diagram for test.test_funcattrs.InstancemethodAttrTest:
Inheritance graph
[legend]
Collaboration diagram for test.test_funcattrs.InstancemethodAttrTest:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test___class__
def test___func__
def test___self__
def test___func___non_method
def setUp
def cannot_set_attr

Public Attributes

 fi
 F
 b

Detailed Description

Definition at line 157 of file test_funcattrs.py.


Member Function Documentation

def test.test_funcattrs.FuncAttrsTest.cannot_set_attr (   self,
  obj,
  name,
  value,
  exceptions 
) [inherited]

Definition at line 16 of file test_funcattrs.py.

00016 
00017     def cannot_set_attr(self, obj, name, value, exceptions):
00018         try:
00019             setattr(obj, name, value)
00020         except exceptions:
00021             pass
00022         else:
00023             self.fail("shouldn't be able to set %s to %r" % (name, value))
00024         try:
00025             delattr(obj, name)
00026         except exceptions:
00027             pass
00028         else:
00029             self.fail("shouldn't be able to del %s" % name)
00030 

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_funcattrs.FuncAttrsTest.setUp (   self) [inherited]

Definition at line 6 of file test_funcattrs.py.

00006 
00007     def setUp(self):
00008         class F:
00009             def a(self):
00010                 pass
00011         def b():
00012             return 3
00013         self.fi = F()
00014         self.F = F
00015         self.b = b

Here is the caller graph for this function:

Definition at line 159 of file test_funcattrs.py.

00159 
00160     def test___class__(self):
00161         self.assertEqual(self.fi.a.__self__.__class__, self.F)
00162         self.cannot_set_attr(self.fi.a, "__class__", self.F, TypeError)

Here is the call graph for this function:

Definition at line 163 of file test_funcattrs.py.

00163 
00164     def test___func__(self):
00165         self.assertEqual(self.fi.a.__func__, self.F.a)
00166         self.cannot_set_attr(self.fi.a, "__func__", self.F.a, AttributeError)

Here is the call graph for this function:

Definition at line 171 of file test_funcattrs.py.

00171 
00172     def test___func___non_method(self):
00173         # Behavior should be the same when a method is added via an attr
00174         # assignment
00175         self.fi.id = types.MethodType(id, self.fi)
00176         self.assertEqual(self.fi.id(), id(self.fi))
00177         # Test usage
00178         try:
00179             self.fi.id.unknown_attr
00180         except AttributeError:
00181             pass
00182         else:
00183             self.fail("using unknown attributes should raise AttributeError")
00184         # Test assignment and deletion
00185         self.cannot_set_attr(self.fi.id, 'unknown_attr', 2, AttributeError)
00186 

Here is the call graph for this function:

Definition at line 167 of file test_funcattrs.py.

00167 
00168     def test___self__(self):
00169         self.assertEqual(self.fi.a.__self__, self.fi)
00170         self.cannot_set_attr(self.fi.a, "__self__", self.fi, AttributeError)

Here is the call graph for this function:


Member Data Documentation

Definition at line 14 of file test_funcattrs.py.

Definition at line 13 of file test_funcattrs.py.

Definition at line 12 of file test_funcattrs.py.


The documentation for this class was generated from the following file: