Mercurial > repos > yufei-luo > s_mart
view commons/tools/tests/Test_pathnum2id.py @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line source
import unittest import os from commons.core.utils.FileUtils import FileUtils class Test_pathnum2id( unittest.TestCase ): def setUp( self ): self._inputFileName = "dummyInputPathFile" self._outputFileName = "dummyOutputPathFile" self._expectedFileName = "dummyExpectedPathFile" self._prg = "pathnum2id.py" def test_runWhithoutReturnAtEndOfFile( self ): cDir = os.getcwd() self._createAndFillInputFileWhithoutReturnAtTheEnd() self._createExpectedFile() cmd = self._prg cmd += " -i %s" % ( self._inputFileName ) cmd += " -o %s" % ( self._outputFileName ) os.system( cmd ) self.assertTrue( FileUtils.are2FilesIdentical( self._outputFileName, self._expectedFileName ) ) os.remove( self._inputFileName ) os.remove( self._expectedFileName ) if os.path.exists( self._outputFileName ): os.remove( self._outputFileName ) os.chdir( cDir ) def test_runWhithReturnAtEndOfFile( self ): cDir = os.getcwd() self._createAndFillInputFileWhithReturnAtTheEnd() self._createExpectedFile() cmd = self._prg cmd += " -i %s" % ( self._inputFileName ) cmd += " -o %s" % ( self._outputFileName ) os.system( cmd ) self.assertTrue( FileUtils.are2FilesIdentical( self._outputFileName, self._expectedFileName ) ) os.remove( self._inputFileName ) os.remove( self._expectedFileName ) if os.path.exists( self._outputFileName ): os.remove( self._outputFileName ) os.chdir( cDir ) def _createExpectedFile( self ): f = open(self._expectedFileName, "w") f.write("1\tblumeria_Grouper_590_20:NoCat_1\t91\t108\tDUF234\t5\t22\t1.5\t3.2\t0\n") f.write("2\tblumeria_Grouper_590_20:NoCat_1\t111\t119\tDUF1414\t1\t9\t6.3\t2.9\t0\n") f.write("3\tblumeria_Grouper_590_20:NoCat_3\t30\t37\tCPW_WPC\t1\t9\t7.7\t1.5\t0\n") f.write("4\tblumeria_Grouper_590_20:NoCat_3\t55\t69\tHECT\t341\t355\t9.2e-06\t0.0\t0\n") f.write("5\tblumeria_Grouper_590_20:NoCat_4\t82\t91\tDUF46\t173\t182\t0.11\t6.4\t0\n") f.write("6\tblumeria_Grouper_590_20:NoCat_5\t121\t125\tPOC4\t276\t280\t6.3\t-1.7\t0\n") f.close() def _createAndFillInputFileWhithoutReturnAtTheEnd( self ): f = open(self._inputFileName, "w") f.write("1\tblumeria_Grouper_590_20:NoCat_1\t91\t108\tDUF234\t5\t22\t1.5\t3.2\t0\n") f.write("2\tblumeria_Grouper_590_20:NoCat_1\t111\t119\tDUF1414\t1\t9\t6.3\t2.9\t0\n") f.write("3\tblumeria_Grouper_590_20:NoCat_3\t30\t37\tCPW_WPC\t1\t9\t7.7\t1.5\t0\n") f.write("1\tblumeria_Grouper_590_20:NoCat_3\t55\t69\tHECT\t341\t355\t9.2e-06\t0.0\t0\n") f.write("2\tblumeria_Grouper_590_20:NoCat_4\t82\t91\tDUF46\t173\t182\t0.11\t6.4\t0\n") f.write("3\tblumeria_Grouper_590_20:NoCat_5\t121\t125\tPOC4\t276\t280\t6.3\t-1.7\t0") f.close() def _createAndFillInputFileWhithReturnAtTheEnd( self ): f = open(self._inputFileName, "w") f.write("1\tblumeria_Grouper_590_20:NoCat_1\t91\t108\tDUF234\t5\t22\t1.5\t3.2\t0\n") f.write("2\tblumeria_Grouper_590_20:NoCat_1\t111\t119\tDUF1414\t1\t9\t6.3\t2.9\t0\n") f.write("3\tblumeria_Grouper_590_20:NoCat_3\t30\t37\tCPW_WPC\t1\t9\t7.7\t1.5\t0\n") f.write("1\tblumeria_Grouper_590_20:NoCat_3\t55\t69\tHECT\t341\t355\t9.2e-06\t0.0\t0\n") f.write("2\tblumeria_Grouper_590_20:NoCat_4\t82\t91\tDUF46\t173\t182\t0.11\t6.4\t0\n") f.write("3\tblumeria_Grouper_590_20:NoCat_5\t121\t125\tPOC4\t276\t280\t6.3\t-1.7\t0\n") f.close() if __name__ == "__main__": unittest.main()