Example #1
0
def WriteErrorsToFile():
    """Write errors to file and clear log"""
    if(not __errorsTracked__ is None):
        if(len(__errorsTracked__)>0):
            formattedLogName = '_'.join["ErrorLog","GarageChecker",datetime.date,datetime.time]
            WriteToFile(formattedLogName,__errorsTracked__)
            __errorsTracked__ = []
 def testCorrectRemoveFileAtPath(self):
     dict2 = {'something2': 'value2'}
     WriteToFile(
         os.path.join(os.getcwd(), '__tests__', 'FileUtilityTestFolder',
                      'FileSystemTest.txt'), dict2)
     self.failUnlessEqual(
         RemoveFileAtPath(
             os.path.join(os.getcwd(), '__tests__', 'FileUtilityTestFolder',
                          'FileSystemTest.txt')), None)
    def testCorrectGetListFromFolderOfExt(self):
        dict2 = {'something2': 'value2'}
        WriteToFile(
            os.path.join(os.getcwd(), '__tests__', 'FileUtilityTestFolder',
                         'FileSystemTest.txt'), dict2)

        self.failUnlessEqual(
            GetListFromFolderOfExt(
                os.path.join(os.getcwd(), '__tests__',
                             'FileUtilityTestFolder'), '.txt'),
            ['FileSystemTest'])
 def testCorrectCopyFileFromTo(self):
     dict2 = {'something2': 'value2'}
     WriteToFile(
         os.path.join(os.getcwd(), '__tests__', 'FileUtilityTestFolder',
                      'FileSystemTest.txt'), dict2)
     self.failUnlessEqual(
         CopyFileFromTo(
             os.path.join(os.getcwd(), '__tests__', 'FileUtilityTestFolder',
                          'FileSystemTest.txt'),
             os.path.join(os.getcwd(), '__tests__',
                          'FileUtilityTestFolderCopyToTest',
                          'FileSystemTest.txt')), None)
 def testCorrectBuildDictFromFolderWithExt(self):
     dict2 = {'something2': 'value2'}
     WriteToFile(
         os.path.join(os.getcwd(), '__tests__', 'FileUtilityTestFolder',
                      'FileSystemTest.txt'), dict2)
     self.failUnlessEqual(
         BuildDictFromFolderWithExt(
             os.path.join(os.getcwd(), '__tests__',
                          'FileUtilityTestFolder'), '.txt', False),
         {
             'FileSystemTest': [
                 os.path.join(os.getcwd(), '__tests__',
                              'FileUtilityTestFolder', 'FileSystemTest.txt')
             ]
         })
 def testFailWriteToFileUnlessRaises(self):
     with self.failUnlessRaises(TypeError):
         WriteToFile(132, ['something2'])
     with self.failUnlessRaises(ValueError):
         WriteToFile('fail.txt', ['something2'])