Back to index

python3.2  3.2.2
Public Member Functions
test.test_isinstance.TestIsInstanceExceptions Class Reference

List of all members.

Public Member Functions

def test_class_has_no_bases
def test_bases_raises_other_than_attribute_error
def test_dont_mask_non_attribute_error
def test_mask_attribute_error
def test_isinstance_dont_mask_non_attribute_error

Detailed Description

Definition at line 11 of file test_isinstance.py.


Member Function Documentation

Definition at line 42 of file test_isinstance.py.

00042 
00043     def test_bases_raises_other_than_attribute_error(self):
00044         class E(object):
00045             def getbases(self):
00046                 raise RuntimeError
00047             __bases__ = property(getbases)
00048 
00049         class I(object):
00050             def getclass(self):
00051                 return E()
00052             __class__ = property(getclass)
00053 
00054         class C(object):
00055             def getbases(self):
00056                 return ()
00057             __bases__ = property(getbases)
00058 
00059         self.assertRaises(RuntimeError, isinstance, I(), C())

Here is the call graph for this function:

Definition at line 26 of file test_isinstance.py.

00026 
00027     def test_class_has_no_bases(self):
00028         class I(object):
00029             def getclass(self):
00030                 # This must return an object that has no __bases__ attribute
00031                 return None
00032             __class__ = property(getclass)
00033 
00034         class C(object):
00035             def getbases(self):
00036                 return ()
00037             __bases__ = property(getbases)
00038 
00039         self.assertEqual(False, isinstance(I(), C()))

Here is the call graph for this function:

Definition at line 62 of file test_isinstance.py.

00062 
00063     def test_dont_mask_non_attribute_error(self):
00064         class I: pass
00065 
00066         class C(object):
00067             def getbases(self):
00068                 raise RuntimeError
00069             __bases__ = property(getbases)
00070 
00071         self.assertRaises(RuntimeError, isinstance, I(), C())

Here is the call graph for this function:

Definition at line 86 of file test_isinstance.py.

00086 
00087     def test_isinstance_dont_mask_non_attribute_error(self):
00088         class C(object):
00089             def getclass(self):
00090                 raise RuntimeError
00091             __class__ = property(getclass)
00092 
00093         c = C()
00094         self.assertRaises(RuntimeError, isinstance, c, bool)
00095 
00096         # test another code path
00097         class D: pass
00098         self.assertRaises(RuntimeError, isinstance, c, D)
00099 
00100 
00101 # These tests are similar to above, but tickle certain code paths in
00102 # issubclass() instead of isinstance() -- really PyObject_IsSubclass()
# vs. PyObject_IsInstance().

Here is the call graph for this function:

Definition at line 74 of file test_isinstance.py.

00074 
00075     def test_mask_attribute_error(self):
00076         class I: pass
00077 
00078         class C(object):
00079             def getbases(self):
00080                 raise AttributeError
00081             __bases__ = property(getbases)
00082 
00083         self.assertRaises(TypeError, isinstance, I(), C())

Here is the call graph for this function:


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