Back to index

python3.2  3.2.2
Public Member Functions
test.test_opcodes.OpcodeTest Class Reference

List of all members.

Public Member Functions

def test_try_inside_for_loop
def test_raise_class_exceptions
def test_compare_function_objects
def test_modulo_of_string_subclasses

Detailed Description

Definition at line 6 of file test_opcodes.py.


Member Function Documentation

Definition at line 67 of file test_opcodes.py.

00067 
00068     def test_compare_function_objects(self):
00069 
00070         f = eval('lambda: None')
00071         g = eval('lambda: None')
00072         self.assertNotEqual(f, g)
00073 
00074         f = eval('lambda a: a')
00075         g = eval('lambda a: a')
00076         self.assertNotEqual(f, g)
00077 
00078         f = eval('lambda a=1: a')
00079         g = eval('lambda a=1: a')
00080         self.assertNotEqual(f, g)
00081 
00082         f = eval('lambda: 0')
00083         g = eval('lambda: 1')
00084         self.assertNotEqual(f, g)
00085 
00086         f = eval('lambda: None')
00087         g = eval('lambda a: None')
00088         self.assertNotEqual(f, g)
00089 
00090         f = eval('lambda a: None')
00091         g = eval('lambda b: None')
00092         self.assertNotEqual(f, g)
00093 
00094         f = eval('lambda a: None')
00095         g = eval('lambda a=None: None')
00096         self.assertNotEqual(f, g)
00097 
00098         f = eval('lambda a=0: None')
00099         g = eval('lambda a=1: None')
00100         self.assertNotEqual(f, g)

Here is the call graph for this function:

Definition at line 101 of file test_opcodes.py.

00101 
00102     def test_modulo_of_string_subclasses(self):
00103         class MyString(str):
00104             def __mod__(self, value):
00105                 return 42
00106         self.assertEqual(MyString() % 3, 42)
00107 

Here is the call graph for this function:

Definition at line 24 of file test_opcodes.py.

00024 
00025     def test_raise_class_exceptions(self):
00026 
00027         class AClass(Exception): pass
00028         class BClass(AClass): pass
00029         class CClass(Exception): pass
00030         class DClass(AClass):
00031             def __init__(self, ignore):
00032                 pass
00033 
00034         try: raise AClass()
00035         except: pass
00036 
00037         try: raise AClass()
00038         except AClass: pass
00039 
00040         try: raise BClass()
00041         except AClass: pass
00042 
00043         try: raise BClass()
00044         except CClass: self.fail()
00045         except: pass
00046 
00047         a = AClass()
00048         b = BClass()
00049 
00050         try:
00051             raise b
00052         except AClass as v:
00053             self.assertEqual(v, b)
00054         else:
00055             self.fail("no exception")
00056 
00057         # not enough arguments
00058         ##try:  raise BClass, a
00059         ##except TypeError: pass
00060         ##else: self.fail("no exception")
00061 
00062         try:  raise DClass(a)
00063         except DClass as v:
00064             self.assertIsInstance(v, DClass)
00065         else:
00066             self.fail("no exception")

Here is the call graph for this function:

Definition at line 8 of file test_opcodes.py.

00008 
00009     def test_try_inside_for_loop(self):
00010         n = 0
00011         for i in range(10):
00012             n = n+i
00013             try: 1/0
00014             except NameError: pass
00015             except ZeroDivisionError: pass
00016             except TypeError: pass
00017             try: pass
00018             except: pass
00019             try: pass
00020             finally: pass
00021             n = n+i
00022         if n != 90:
00023             self.fail('try inside for')

Here is the call graph for this function:


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