def TestGenerated():
    from win32com.client.gencache import EnsureDispatch
    o = EnsureDispatch('PyCOMTest.PyCOMTest')
    TestCommon(o, True)
    counter = EnsureDispatch('PyCOMTest.SimpleCounter')
    TestCounter(counter, True)
    from win32com.client.CLSIDToClass import GetClass
    coclass_o = GetClass('{8EE0C520-5605-11D0-AE5F-CADD4C000000}')()
    TestCommon(coclass_o, True)
    assert bool(coclass_o)
    coclass = GetClass('{B88DD310-BAE8-11D0-AE86-76F2C1000000}')()
    TestCounter(coclass, True)
    (i1, i2) = o.GetMultipleInterfaces()
    if ((not isinstance(i1, DispatchBaseClass)) or (not isinstance(i2, DispatchBaseClass))):
        raise error(("GetMultipleInterfaces did not return instances - got '%s', '%s'" % (i1, i2)))
    del i1
    del i2
    check_get_set_raises(OverflowError, o.GetSetInt, 2147483648)
    check_get_set_raises(OverflowError, o.GetSetLong, 2147483648)
    check_get_set_raises(ValueError, o.GetSetInt, 'foo')
    check_get_set_raises(ValueError, o.GetSetLong, 'foo')
    try:
        o.SetVariantSafeArray('foo')
        raise error('Expected a type error')
    except TypeError:
        pass
    try:
        o.SetVariantSafeArray(666)
        raise error('Expected a type error')
    except TypeError:
        pass
    o.GetSimpleSafeArray(None)
    TestApplyResult(o.GetSimpleSafeArray, (None,), tuple(range(10)))
    resultCheck = (tuple(range(5)), tuple(range(10)), tuple(range(20)))
    TestApplyResult(o.GetSafeArrays, (None, None, None), resultCheck)
    l = []
    TestApplyResult(o.SetIntSafeArray, (l,), len(l))
    l = [1, 2, 3, 4]
    TestApplyResult(o.SetIntSafeArray, (l,), len(l))
    ll = [1, 2, 3, 4294967296]
    TestApplyResult(o.SetLongLongSafeArray, (ll,), len(ll))
    TestApplyResult(o.SetULongLongSafeArray, (ll,), len(ll))
    TestApplyResult(o.Test2, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test3, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test4, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test5, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test6, (constants.WideAttr1,), constants.WideAttr1)
    TestApplyResult(o.Test6, (constants.WideAttr2,), constants.WideAttr2)
    TestApplyResult(o.Test6, (constants.WideAttr3,), constants.WideAttr3)
    TestApplyResult(o.Test6, (constants.WideAttr4,), constants.WideAttr4)
    TestApplyResult(o.Test6, (constants.WideAttr5,), constants.WideAttr5)
    TestApplyResult(o.TestInOut, (2.0, True, 4), (4.0, False, 8))
    o.SetParamProp(0, 1)
    if (o.ParamProp(0) != 1):
        raise RuntimeError(o.paramProp(0))
    o2 = CastTo(o, 'IPyCOMTest')
    if (o != o2):
        raise error('CastTo should have returned the same object')
    progress('Testing connection points')
    o2 = win32com.client.DispatchWithEvents(o, RandomEventHandler)
    TestEvents(o2, o2)
    o2 = win32com.client.DispatchWithEvents(o, NewStyleRandomEventHandler)
    TestEvents(o2, o2)
    handler = win32com.client.WithEvents(o, RandomEventHandler)
    TestEvents(o, handler)
    handler = win32com.client.WithEvents(o, NewStyleRandomEventHandler)
    TestEvents(o, handler)
    progress('Finished generated .py test.')
def TestGenerated():
    from win32com.client.gencache import EnsureDispatch
    o = EnsureDispatch('PyCOMTest.PyCOMTest')
    TestCommon(o, True)
    counter = EnsureDispatch('PyCOMTest.SimpleCounter')
    TestCounter(counter, True)
    from win32com.client.CLSIDToClass import GetClass
    coclass_o = GetClass('{8EE0C520-5605-11D0-AE5F-CADD4C000000}')()
    TestCommon(coclass_o, True)
    assert bool(coclass_o)
    coclass = GetClass('{B88DD310-BAE8-11D0-AE86-76F2C1000000}')()
    TestCounter(coclass, True)
    (i1, i2) = o.GetMultipleInterfaces()
    if ((not isinstance(i1, DispatchBaseClass)) or (not isinstance(i2, DispatchBaseClass))):
        raise error(("GetMultipleInterfaces did not return instances - got '%s', '%s'" % (i1, i2)))
    del i1
    del i2
    check_get_set_raises(OverflowError, o.GetSetInt, 2147483648)
    check_get_set_raises(OverflowError, o.GetSetLong, 2147483648)
    check_get_set_raises(ValueError, o.GetSetInt, 'foo')
    check_get_set_raises(ValueError, o.GetSetLong, 'foo')
    try:
        o.SetVariantSafeArray('foo')
        raise error('Expected a type error')
    except TypeError:
        pass
    try:
        o.SetVariantSafeArray(666)
        raise error('Expected a type error')
    except TypeError:
        pass
    o.GetSimpleSafeArray(None)
    TestApplyResult(o.GetSimpleSafeArray, (None,), tuple(range(10)))
    resultCheck = (tuple(range(5)), tuple(range(10)), tuple(range(20)))
    TestApplyResult(o.GetSafeArrays, (None, None, None), resultCheck)
    l = []
    TestApplyResult(o.SetIntSafeArray, (l,), len(l))
    l = [1, 2, 3, 4]
    TestApplyResult(o.SetIntSafeArray, (l,), len(l))
    ll = [1, 2, 3, 4294967296]
    TestApplyResult(o.SetLongLongSafeArray, (ll,), len(ll))
    TestApplyResult(o.SetULongLongSafeArray, (ll,), len(ll))
    TestApplyResult(o.Test2, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test3, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test4, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test5, (constants.Attr2,), constants.Attr2)
    TestApplyResult(o.Test6, (constants.WideAttr1,), constants.WideAttr1)
    TestApplyResult(o.Test6, (constants.WideAttr2,), constants.WideAttr2)
    TestApplyResult(o.Test6, (constants.WideAttr3,), constants.WideAttr3)
    TestApplyResult(o.Test6, (constants.WideAttr4,), constants.WideAttr4)
    TestApplyResult(o.Test6, (constants.WideAttr5,), constants.WideAttr5)
    TestApplyResult(o.TestInOut, (2.0, True, 4), (4.0, False, 8))
    o.SetParamProp(0, 1)
    if (o.ParamProp(0) != 1):
        raise RuntimeError(o.paramProp(0))
    o2 = CastTo(o, 'IPyCOMTest')
    if (o != o2):
        raise error('CastTo should have returned the same object')
    progress('Testing connection points')
    o2 = win32com.client.DispatchWithEvents(o, RandomEventHandler)
    TestEvents(o2, o2)
    o2 = win32com.client.DispatchWithEvents(o, NewStyleRandomEventHandler)
    TestEvents(o2, o2)
    handler = win32com.client.WithEvents(o, RandomEventHandler)
    TestEvents(o, handler)
    handler = win32com.client.WithEvents(o, NewStyleRandomEventHandler)
    TestEvents(o, handler)
    progress('Finished generated .py test.')