Exemplo n.º 1
0
 def testCanCreateSniffedReader(self):
     testFileNames = ["valid_customers.csv", "valid_customers.ods", "valid_customers.xls"]
     for testFileName in testFileNames:
         testFilePath = dev_test.getTestInputPath(testFileName)
         testFile = open(testFilePath, "rb")
         try:
             reader = sniff.createReader(testFile)
             rowCount = 0
             for _ in reader:
                 rowCount += 1
             self.assertTrue(rowCount > 0)
         finally:
             testFile.close()
Exemplo n.º 2
0
    def testCanCreateSniffedReaderForEmptyData(self):
        emptyReadable = StringIO.StringIO("")

        self.assertTrue(sniff.delimitedOptions(emptyReadable))

        emptyDataFormat = sniff.createDataFormat(emptyReadable)
        self.assertTrue(emptyDataFormat)
        self.assertEqual(emptyDataFormat.name, data.FORMAT_DELIMITED)

        emptyReader = sniff.createReader(emptyReadable)
        self.assertTrue(emptyReadable)
        rowCount = 0
        for _ in emptyReader:
            rowCount += 1
        self.assertEqual(rowCount, 0)
Exemplo n.º 3
0
 def testCanCreateSniffedReader(self):
     testFileNames = [
         "valid_customers.csv", "valid_customers.ods", "valid_customers.xls"
     ]
     for testFileName in testFileNames:
         testFilePath = dev_test.getTestInputPath(testFileName)
         testFile = open(testFilePath, "rb")
         try:
             reader = sniff.createReader(testFile)
             rowCount = 0
             for _ in reader:
                 rowCount += 1
             self.assertTrue(rowCount > 0)
         finally:
             testFile.close()
Exemplo n.º 4
0
    def testCanCreateSniffedReaderForEmptyData(self):
        emptyReadable = StringIO.StringIO("")

        self.assertTrue(sniff.delimitedOptions(emptyReadable))

        emptyDataFormat = sniff.createDataFormat(emptyReadable)
        self.assertTrue(emptyDataFormat)
        self.assertEqual(emptyDataFormat.name, data.FORMAT_DELIMITED)

        emptyReader = sniff.createReader(emptyReadable)
        self.assertTrue(emptyReadable)
        rowCount = 0
        for _ in emptyReader:
            rowCount += 1
        self.assertEqual(rowCount, 0)