<s> import datetime <EOL> import os <EOL> import re <EOL> import shlex <EOL> import shutil <EOL> from . common import GrTest , git_results , addExec , checked <EOL> def checkTag ( tag ) : <EOL> """<STR_LIT>""" <EOL> o = checked ( "<STR_LIT>" . format ( tag ) ) <EOL> if not o . strip ( ) : <EOL> return None <EOL> return checked ( "<STR_LIT>" . format ( tag ) ) . strip ( ) . split ( "<STR_LIT:\n>" ) [ <EOL> <NUM_LIT:0> ] . strip ( ) <EOL> class TestGitResults ( GrTest ) : <EOL> def _assertTagMatchesMessage ( self , tag , suffix = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> commit = re . search ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' . format ( tag + suffix ) ) . read ( ) , <EOL> re . M ) <EOL> self . assertNotEqual ( None , commit ) <EOL> commit = commit . group ( <NUM_LIT:1> ) <EOL> self . assertEqual ( commit , checkTag ( tag ) ) <EOL> def _getDatedBase ( self ) : <EOL> now = datetime . datetime . now ( ) <EOL> return os . path . join ( '<STR_LIT>' , '<STR_LIT>' , now . strftime ( '<STR_LIT>' ) , <EOL> now . strftime ( '<STR_LIT>' ) , now . strftime ( '<STR_LIT>' ) ) <EOL> def _setupRepo ( self ) : <EOL> """<STR_LIT>""" <EOL> self . initAndChdirTmp ( ) <EOL> checked ( "<STR_LIT>" ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> f . write ( "<STR_LIT>" ) <EOL> addExec ( "<STR_LIT>" ) <EOL> checked ( "<STR_LIT>" ) <EOL> checked ( "<STR_LIT>" ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> addExec ( "<STR_LIT>" ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> addExec ( "<STR_LIT>" ) <EOL> def test_buildFail ( self ) : <EOL> self . _setupRepo ( ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( None , checkTag ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> def test_followCmd ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( '<STR_LIT>' ) . read ( ) ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( <EOL> "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> def test_gitGetsTag ( self ) : <EOL> self . _setupRepo ( ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( r"""<STR_LIT>""" ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( r"""<STR_LIT>""" ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> def test_link ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> with self . assertRaises ( ValueError ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . assertEqual ( checkTag ( "<STR_LIT>" ) , <EOL> checkTag ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> def test_move ( self ) : <EOL> self . _setupRepo ( ) <EOL> dateBase = self . _getDatedBase ( ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( None , checkTag ( "<STR_LIT>" ) ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> print ( "<STR_LIT>" . format ( dateBase + "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( dateBase + '<STR_LIT>' ) ) <EOL> self . assertEqual ( True , os . path . lexists ( dateBase + '<STR_LIT>' ) ) <EOL> self . assertEqual ( False , os . path . lexists ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( True , <EOL> os . path . lexists ( '<STR_LIT>' ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> def test_moveExperiment ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> dateBase = self . _getDatedBase ( ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( False , os . path . lexists ( dateBase + '<STR_LIT>' ) ) <EOL> self . assertEqual ( True , os . path . lexists ( dateBase + '<STR_LIT>' ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> def test_moveFail ( self ) : <EOL> self . _setupRepo ( ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> dateBase = self . _getDatedBase ( ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> try : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> except SystemExit , e : <EOL> self . fail ( str ( e ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( dateBase + "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( dateBase + "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( dateBase + "<STR_LIT>" ) . read ( ) ) <EOL> def test_moveSingle ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> with self . assertRaises ( ValueError ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> with self . assertRaises ( ValueError ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> def test_moveSub ( self ) : <EOL> self . _setupRepo ( ) <EOL> os . makedirs ( "<STR_LIT>" ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> pass <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> addExec ( "<STR_LIT>" ) <EOL> addExec ( "<STR_LIT>" ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> os . chdir ( "<STR_LIT>" ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> print ( "<STR_LIT>" ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> os . chdir ( "<STR_LIT:..>" ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> ex = [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> noex = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> for path in ex : <EOL> print ( "<STR_LIT>" . format ( path ) ) <EOL> self . assertTrue ( os . path . lexists ( "<STR_LIT>" + path ) ) <EOL> for path in noex : <EOL> print ( "<STR_LIT>" . format ( path ) ) <EOL> self . assertFalse ( os . path . lexists ( "<STR_LIT>" + path ) ) <EOL> mainIndex = "<STR_LIT>" <EOL> self . assertEqual ( mainIndex , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> otherIndex = "<STR_LIT>" <EOL> self . assertEqual ( otherIndex , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> otherIndex = "<STR_LIT>" <EOL> self . assertEqual ( otherIndex , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> def test_multiple ( self ) : <EOL> self . _setupRepo ( ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> os . makedirs ( "<STR_LIT>" ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> pass <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> addExec ( "<STR_LIT>" ) <EOL> addExec ( "<STR_LIT>" ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> try : <EOL> os . chdir ( "<STR_LIT>" ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> finally : <EOL> os . chdir ( "<STR_LIT:..>" ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> def test_noMessage ( self ) : <EOL> self . _setupRepo ( ) <EOL> try : <EOL> try : <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> except ValueError , e : <EOL> self . assertEqual ( "<STR_LIT>" <EOL> "<STR_LIT>" , str ( e ) ) <EOL> try : <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> except ValueError , e : <EOL> self . assertEqual ( "<STR_LIT>" <EOL> "<STR_LIT>" , str ( e ) ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> except SystemExit , e : <EOL> self . fail ( str ( e ) ) <EOL> '''<STR_LIT>''' <EOL> def test_basic ( self ) : <EOL> self . _setupRepo ( ) <EOL> now = datetime . datetime . now ( ) <EOL> datedFolder = '<STR_LIT>' . format ( <EOL> now . strftime ( "<STR_LIT>" ) , now . strftime ( "<STR_LIT>" ) , now . strftime ( "<STR_LIT>" ) ) <EOL> try : <EOL> git_results . run ( shlex . split ( '<STR_LIT>' <EOL> '<STR_LIT>' ) ) <EOL> except SystemExit , e : <EOL> self . fail ( str ( e ) ) <EOL> self . assertTrue ( checked ( <EOL> "<STR_LIT>" ) <EOL> . startswith ( "<STR_LIT>" ) ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( os . path . join ( datedFolder , '<STR_LIT>' ) ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( '<STR_LIT>' ) . read ( ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT:.>' ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' ) . read ( ) ) <EOL> with open ( "<STR_LIT>" , "<STR_LIT:w>" ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> def testFail ( n ) : <EOL> pth = "<STR_LIT>" . format ( n ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" . format ( n ) , <EOL> "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' . format ( pth ) ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( os . path . join ( datedFolder , '<STR_LIT>' . format ( pth ) ) <EOL> ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> err = open ( '<STR_LIT>' . format ( pth ) ) . read ( ) <EOL> self . assertIn ( "<STR_LIT>" , err . lower ( ) ) <EOL> self . assertIn ( "<STR_LIT>" , err . lower ( ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT:.>' ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT>' <EOL> . format ( pth ) ) ) <EOL> testFail ( <NUM_LIT:2> ) <EOL> self . assertEqual ( False , os . path . lexists ( '<STR_LIT>' ) ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> testFail ( <NUM_LIT:3> ) <EOL> self . assertEqual ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> open ( '<STR_LIT>' ) . read ( ) ) <EOL> def test_extraFile ( self ) : <EOL> self . _setupRepo ( ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> try : <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( <EOL> "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( <EOL> "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( "<STR_LIT>" ) . read ( ) ) <EOL> finally : <EOL> os . remove ( '<STR_LIT>' ) <EOL> def test_continuation ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> shutil . rmtree ( "<STR_LIT>" ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> def test_failToMoveResults ( self ) : <EOL> old = git_results . FolderState . moveResultsTo <EOL> def newMove ( self , dir , trimCommonPaths = False ) : <EOL> oldRename = os . rename <EOL> def newRename ( a , b ) : <EOL> print "<STR_LIT>" . format ( a ) <EOL> if os . path . basename ( a ) == "<STR_LIT>" : <EOL> raise OSError ( <NUM_LIT> , "<STR_LIT>" ) <EOL> else : <EOL> return oldRename ( a , b ) <EOL> os . rename = newRename <EOL> try : <EOL> return old ( self , dir , trimCommonPaths = trimCommonPaths ) <EOL> finally : <EOL> os . rename = oldRename <EOL> git_results . FolderState . moveResultsTo = newMove <EOL> try : <EOL> self . _setupRepo ( ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> f . write ( "<STR_LIT>" ) <EOL> f . write ( "<STR_LIT>" ) <EOL> with self . assertRaises ( SystemExit ) : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( False , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( True , os . path . lexists ( "<STR_LIT>" ) ) <EOL> self . assertIn ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> finally : <EOL> git_results . FolderState . moveResultsTo = old <EOL> def test_indexAbort ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> try : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . fail ( "<STR_LIT>" ) <EOL> except SystemExit : <EOL> pass <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' ) . read ( ) ) <EOL> with open ( '<STR_LIT>' , '<STR_LIT:w>' ) as f : <EOL> f . write ( "<STR_LIT>" ) <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' ) . read ( ) ) <EOL> def test_indexUtils ( self ) : <EOL> self . _setupRepo ( ) <EOL> def contents ( f ) : <EOL> with open ( f + '<STR_LIT>' ) as fp : <EOL> return fp . read ( ) <EOL> git_results . indexWrite ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , contents ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( ( '<STR_LIT:1>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> git_results . indexRead ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> git_results . indexWrite ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> contents ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( ( '<STR_LIT:1>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> git_results . indexRead ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( ( '<STR_LIT:2>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> git_results . indexRead ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> git_results . indexWrite ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> contents ( "<STR_LIT>" ) ) <EOL> self . assertEqual ( ( '<STR_LIT:1>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> git_results . indexRead ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> self . assertEqual ( ( '<STR_LIT:2>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> git_results . indexRead ( "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> def test_inPlace ( self ) : <EOL> self . _setupRepo ( ) <EOL> try : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" ) ) <EOL> except SystemExit , e : <EOL> self . fail ( str ( e ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( '<STR_LIT>' ) . read ( ) ) <EOL> self . assertIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT:.>' ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT>' ) ) <EOL> self . assertIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT>' ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT:.>' ) ) <EOL> def test_pFlag ( self ) : <EOL> self . _setupRepo ( ) <EOL> now = datetime . datetime . now ( ) <EOL> datedFolder = '<STR_LIT>' . format ( <EOL> now . strftime ( "<STR_LIT>" ) , now . strftime ( "<STR_LIT>" ) , now . strftime ( "<STR_LIT>" ) ) <EOL> try : <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> except SystemExit , e : <EOL> self . fail ( str ( e ) ) <EOL> self . assertTrue ( checked ( <EOL> "<STR_LIT>" ) <EOL> . startswith ( "<STR_LIT>" ) ) <EOL> self . _assertTagMatchesMessage ( "<STR_LIT>" ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( '<STR_LIT>' ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( os . path . join ( datedFolder , '<STR_LIT>' ) ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> self . assertEqual ( "<STR_LIT>" , open ( '<STR_LIT>' ) . read ( ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT:.>' ) ) <EOL> self . assertNotIn ( '<STR_LIT>' , os . listdir ( '<STR_LIT>' ) ) <EOL> def test_readme ( self ) : <EOL> self . initAndChdirTmp ( ) <EOL> checked ( "<STR_LIT>" ) <EOL> checked ( "<STR_LIT>" ) <EOL> checked ( "<STR_LIT>" ) <EOL> checked ( "<STR_LIT>" ) <EOL> try : <EOL> git_results . run ( shlex . split ( "<STR_LIT>" <EOL> "<STR_LIT>" ) ) <EOL> except SystemExit , e : <EOL> self . fail ( str ( e ) ) <EOL> self . assertEqual ( "<STR_LIT>" , <EOL> open ( "<STR_LIT>" ) . read ( ) ) <EOL> def test_tagFail ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( os . path . lexists ( "<STR_LIT>" ) ) <EOL> shutil . rmtree ( "<STR_LIT>" ) <EOL> with self . assertRaises ( Exception ) : <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> self . assertFalse ( os . path . lexists ( "<STR_LIT>" ) ) <EOL> def test_tagNextFromIndex ( self ) : <EOL> self . _setupRepo ( ) <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( os . path . lexists ( "<STR_LIT>" ) ) <EOL> shutil . rmtree ( "<STR_LIT>" ) <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( os . path . lexists ( "<STR_LIT>" ) ) <EOL> shutil . rmtree ( "<STR_LIT>" ) <EOL> git_results . run ( shlex . split ( '<STR_LIT>' ) ) <EOL> self . assertTrue ( os . path . lexists ( "<STR_LIT>" ) ) </s>
