a oe @s8ddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZmZddlmZdejvZGd d d e jZGd d d ejZGd ddZedZGdddejZdZdZdZ dZ!ej"dej#dej$dej%dej&dej'diZ(ddZ)Gdddej*jj+Z,e-d kr4e.dS)!N)axscript)axsite) Exception)Dispatch)connectutil) COMExceptionz-vc@seZdZddZddZdS)MySitecGsd|_tjj|g|RdSN)exception_seenrAXSite__init__)selfargsrCC:\Program Files\Certbot\pkgs\win32comext\axscript\test\testHost.pyr szMySite.__init__cCs||_}|\}}}ts$dStd|dz |}WntjyVd}Yn0|durdd}|dd|ddd|d}|D]}td|qdS) Nz >Exception:  ^z >) ZGetExceptionInfor ZGetSourcePositionverboseprintZGetSourceLineText pythoncom com_error splitlines)rerrorexccontextlinecharsttextrrr OnScriptErrors  $ zMySite.OnScriptErrorN)__name__ __module__ __qualname__r r$rrrrr sr c@seZdZddZdS) MyCollectioncCs tj|Sr )r Collection_NewEnumrrrrr*(szMyCollection._NewEnumN)r%r&r'r*rrrrr('sr(c@s2eZdZddgZdgZddZddZdd Zd S) Testechofail collectioncCs*t|_ttgd|_d|_d|_dS)N)rZTworr)rrwrapr(r/last fail_calledr+rrrr 0sz Test.__init__cGs<ddd|D|_|jr8|D]}t|ddq tdS)NrcSsg|] }t|qSr)str).0srrr 9zTest.echo..rend)joinr2rrrrargrrrr-8s z Test.echocGs.td|D]}t|ddq td|_dS)Nz**** fail() called ***rr9r)rr3r<rrrr.?s z Test.failN)r%r&r'Z_public_methods_Z_public_attrs_r r-r.rrrrr,,s r,z&{8EB72F90-0D44-11d1-9C4B-00AA00125A98}c@s*eZdZegZddZddZddZdS)TestConnectServercCs ||_dSr )object)rr?rrrr UszTestConnectServer.__init__cCs||j|fdSr )Z_BroadcastNotify NotifyDoneIt)rr=rrr BroadcastXszTestConnectServer.BroadcastcCs|ddtjd|dS)Nirr)ZInvokerZDISPATCH_METHOD)rZ interfacer=rrrr@\szTestConnectServer.NotifyDoneItN)r%r&r'IID_ITestEventsZ_connect_interfaces_r rAr@rrrrr>Psr>aprop = "Property Value" sub hello(arg1) test.echo arg1 end sub sub testcollection if test.collection.Item(0) <> 1 then test.fail("Index 0 was wrong") end if if test.collection.Item(1) <> "Two" then test.fail("Index 1 was wrong") end if if test.collection.Item(2) <> 3 then test.fail("Index 2 was wrong") end if num = 0 for each item in test.collection num = num + 1 next if num <> 3 then test.fail("Collection didn't have 3 items") end if end sub u!# A unicode ©omment. prop = "Property Value" def hello(arg1): test.echo(arg1) def testcollection(): # test.collection[1] = "New one" got = [] for item in test.collection: got.append(item) if got != [1, "Two", 3]: test.fail("Didn't get the collection") pass uAdef hello(arg1): raise RuntimeError("exc with extended ©har") zbad code for everyone! SCRIPTSTATE_UNINITIALIZEDSCRIPTSTATE_INITIALIZEDSCRIPTSTATE_STARTEDSCRIPTSTATE_CONNECTEDSCRIPTSTATE_DISCONNECTEDSCRIPTSTATE_CLOSEDcCsJ|jj}||krFt|t|}t|t|}td|||fdS)Nz1Warning - engine %s has state %s, but expected %s)engineZeScriptZGetScriptState state_mapgetr4 RuntimeError)rInamestateZgotZgot_nameZ state_namerrr_CheckEngineStates rOc@s>eZdZdddZddZddZdd Zd d Zd d ZdS) EngineTesterNc Cs>t}dt|i}t|}||}zt||tj||| t||tj | |j dt |}z$|d| |dud|fWnjtjy|dur|d|jf||jdvr|d||jdfYW|d}d}dS0||jd|t|jd|| |j d|jd dddd d tj} || d|tjt||tj| t||tj |tjt||tj|tjt||tj|tjt||tj|tjt||tj|tjt||tjW|d}d}n|d}d}0dS) Ntestz Fail should not have been calledZGooberz"Expected %r, but no exception seenz'Unexpected failure from script code: %srzCould not find %r in %rzProperty Valuez1+1r) r,rr1r Z _AddEnginerOrrDZAddCodeZStartrEZ assertTruer3rZGetScriptDispatchZhellorrr.r CloseZ assertEqualr2r4ZpropZtestcollectionZeParseZParseScriptTextZSCRIPTTEXT_ISEXPRESSIONZSetScriptStaterFrG) rZ engineNamecodeZ expected_excZechoerZmodelZsiterIobresultrrr _TestEngines             zEngineTester._TestEnginecCs|dtdSNVBScript)rVrXr+rrrtestVBszEngineTester.testVBcCs|dtdSNPythonrVPyScriptr+rrr testPythonszEngineTester.testPythoncCs|dtdSrZr\r+rrrtestPythonUnicodeErrorsz#EngineTester.testPythonUnicodeErrorcCs|tj|jdtdSrW)Z assertRaisesrrrV ErrScriptr+rrrtestVBExceptionsszEngineTester.testVBExceptionscCsd}|dt|dS)Nu%RuntimeError: exc with extended ©harr[)rV PyScript_Exc)rZexpectedrrrtestPythonExceptionssz!EngineTester.testPythonExceptions)N) r%r&r'rVrYr^r_rarcrrrrrPs  CrP__main__)/sysZunittestrZwin32com.server.policyZwin32comZwin32com.test.utilZwin32com.axscriptrZwin32com.axscript.serverrZwin32com.axscript.server.errorrZwin32com.client.dynamicrZwin32com.serverrrZwin32com.server.exceptionrargvrr r r)r(r,ZMakeIIDrBZConnectableServerr>rXr]rbr`rCrDrErFrGrHrJrOrQZTestCaserPr%mainrrrrs>      !   U