Example #1
0
        callback_raise_simple_error, 'fred')
    print('PASS func_with_callback_catch_simple_error returned %r' %
          (answer, ))

except simple.SimpleError as e:
    print('FAIL func_with_callback_catch_simple_error: %s' % (e, ))

print('TEST: raise SimpleError')
try:
    raise simple.SimpleError('Hello!')

except simple.SimpleError as e:
    print('PASS caught SimpleError - %s' % (e, ))

print('TEST: call old style class functions')
old_style_class = simple.old_style_class()
old_style_class.old_style_class_func_noargs()
old_style_class.old_style_class_func_varargs()
old_style_class.old_style_class_func_varargs(4)
old_style_class.old_style_class_func_keyword()
old_style_class.old_style_class_func_keyword(name=6, value=7)
old_style_class.old_style_class_func_keyword(4, 5)
old_style_class.old_style_class_func_keyword(4, 5, name=6, value=7)

print('TEST: Derived class functions')


class Derived(simple.new_style_class):
    def __init__(self):
        simple.new_style_class.__init__(self)
Example #2
0
import sys
import simple

print('--- module func ---')
simple.func()
simple.func(4, 5)
simple.func(4, 5, name=6, value=7)

print('--- old_style_class func ---')
old_style_class = simple.old_style_class()
old_style_class.old_style_class_func_noargs()
old_style_class.old_style_class_func_varargs()
old_style_class.old_style_class_func_varargs(4)
old_style_class.old_style_class_func_keyword()
old_style_class.old_style_class_func_keyword(name=6, value=7)
old_style_class.old_style_class_func_keyword(4, 5)
old_style_class.old_style_class_func_keyword(4, 5, name=6, value=7)

print('--- Derived func ---')


class Derived(simple.new_style_class):
    def __init__(self):
        simple.new_style_class.__init__(self)

    def derived_func(self):
        print('derived_func')
        super(Derived, self).func_noargs()

    def func_noargs(self):
        print('derived func_noargs')