コード例 #1
0
ファイル: sortTest.py プロジェクト: brainstorm/toil
 def testMerge(self):
     for test in xrange(self.testNo):
         tempFile1 = os.path.join(self.tempDir, "fileToSort1.txt")
         tempFile2 = os.path.join(self.tempDir, "fileToSort2.txt")
         tempFile3 = os.path.join(self.tempDir, "mergedFile.txt")
         makeFileToSort(tempFile1)
         makeFileToSort(tempFile2)
         sort(tempFile1)
         sort(tempFile2)
         with open(tempFile3, 'w') as fileHandle:
             with open(tempFile1) as tempFileHandle1:
                 with open(tempFile2) as tempFileHandle2:
                     merge(tempFileHandle1, tempFileHandle2, fileHandle)
         lines1 = self._loadFile(tempFile1) + self._loadFile(tempFile2)
         lines1.sort()
         with open(tempFile3, 'r') as f:
             lines2 = f.readlines()
         self.assertEquals(lines1, lines2)
コード例 #2
0
ファイル: sortTest.py プロジェクト: yongqian10/toil
 def testMerge(self):
     for test in xrange(self.testNo):
         tempFile1 = os.path.join(self.tempDir, "fileToSort1.txt")
         tempFile2 = os.path.join(self.tempDir, "fileToSort2.txt")
         tempFile3 = os.path.join(self.tempDir, "mergedFile.txt")
         makeFileToSort(tempFile1)
         makeFileToSort(tempFile2)
         sort(tempFile1)
         sort(tempFile2)
         with open(tempFile3, 'w') as fileHandle:
             with open(tempFile1) as tempFileHandle1:
                 with open(tempFile2) as tempFileHandle2:
                     merge(tempFileHandle1, tempFileHandle2, fileHandle)
         lines1 = self._loadFile(tempFile1) + self._loadFile(tempFile2)
         lines1.sort()
         with open(tempFile3, 'r') as f:
             lines2 = f.readlines()
         self.assertEquals(lines1, lines2)