<s> import unittest <EOL> import time <EOL> import comtypes . client <EOL> import comtypes . test <EOL> comtypes . test . requires ( "<STR_LIT>" ) <EOL> class Test ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> self . _events = [ ] <EOL> def DocumentChange ( self , this , * args ) : <EOL> self . _events . append ( "<STR_LIT>" ) <EOL> def test ( self ) : <EOL> word = comtypes . client . CreateObject ( "<STR_LIT>" ) <EOL> from comtypes . gen import Word <EOL> w2 = comtypes . client . GetActiveObject ( "<STR_LIT>" ) <EOL> conn = comtypes . client . GetEvents ( w2 , sink = self ) <EOL> word . Visible = <NUM_LIT:1> <EOL> doc = word . Documents . Add ( ) <EOL> wrange = doc . Range ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> wrange . InsertAfter ( "<STR_LIT>" % i ) <EOL> for i , para in enumerate ( doc . Paragraphs ) : <EOL> f = para . Range . Font <EOL> f . ColorIndex = i + <NUM_LIT:1> <EOL> f . Size = <NUM_LIT:12> + ( <NUM_LIT:2> * i ) <EOL> time . sleep ( <NUM_LIT:0.5> ) <EOL> doc . Close ( SaveChanges = Word . wdDoNotSaveChanges ) <EOL> word . Quit ( ) <EOL> del word , w2 <EOL> time . sleep ( <NUM_LIT:0.5> ) <EOL> def test_commandbar ( self ) : <EOL> word = comtypes . client . CreateObject ( "<STR_LIT>" ) <EOL> word . Visible = <NUM_LIT:1> <EOL> tb = word . CommandBars ( "<STR_LIT>" ) <EOL> btn = tb . Controls [ <NUM_LIT:1> ] <EOL> if <NUM_LIT:0> : <EOL> evt = word . VBE . Events . CommandBarEvents ( btn ) <EOL> from comtypes . gen import Word , VBIDE <EOL> comtypes . client . ShowEvents ( evt , interface = VBIDE . _dispCommandBarControlEvents ) <EOL> comtypes . client . ShowEvents ( evt ) <EOL> word . Quit ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> unittest . main ( ) </s>
