Back to index

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

List of all members.

Public Member Functions

def test_setting_dict_to_invalid
def test_setting_dict_to_valid
def test_delete___dict__
def test_unassigned_dict
def test_func_as_dict_key
def setUp
def cannot_set_attr

Public Attributes

 fi
 F
 b

Detailed Description

Definition at line 217 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 240 of file test_funcattrs.py.

00240 
00241     def test_delete___dict__(self):
00242         try:
00243             del self.b.__dict__
00244         except TypeError:
00245             pass
00246         else:
00247             self.fail("deleting function dictionary should raise TypeError")

Here is the call graph for this function:

Definition at line 251 of file test_funcattrs.py.

00251 
00252     def test_func_as_dict_key(self):
00253         value = "Some string"
00254         d = {}
00255         d[self.b] = value
00256         self.assertEqual(d[self.b], value)
00257 

Here is the call graph for this function:

Definition at line 218 of file test_funcattrs.py.

00218 
00219     def test_setting_dict_to_invalid(self):
00220         self.cannot_set_attr(self.b, '__dict__', None, TypeError)
00221         from collections import UserDict
00222         d = UserDict({'known_attr': 7})
00223         self.cannot_set_attr(self.fi.a.__func__, '__dict__', d, TypeError)

Here is the call graph for this function:

Definition at line 224 of file test_funcattrs.py.

00224 
00225     def test_setting_dict_to_valid(self):
00226         d = {'known_attr': 7}
00227         self.b.__dict__ = d
00228         # Test assignment
00229         self.assertIs(d, self.b.__dict__)
00230         # ... and on all the different ways of referencing the method's func
00231         self.F.a.__dict__ = d
00232         self.assertIs(d, self.fi.a.__func__.__dict__)
00233         self.assertIs(d, self.fi.a.__dict__)
00234         # Test value
00235         self.assertEqual(self.b.known_attr, 7)
00236         self.assertEqual(self.b.__dict__['known_attr'], 7)
00237         # ... and again, on all the different method's names
00238         self.assertEqual(self.fi.a.__func__.known_attr, 7)
00239         self.assertEqual(self.fi.a.known_attr, 7)

Here is the call graph for this function:

Definition at line 248 of file test_funcattrs.py.

00248 
00249     def test_unassigned_dict(self):
00250         self.assertEqual(self.b.__dict__, {})

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: