def test_remove_file(self):
     #Test file that doesn't exist
     result = IO.remove_file("sadksal21r45ewq90&&&&%%!@####:::")
     self.assertFalse(result)
     
     #Test file that does exist
     IO.ensfile("test_remove_file.exe")
     result = IO.remove_file("test_remove_file.exe")
     self.assertTrue(result)
     
     #Test file that exists, but can't be removed.
     IO.ensfile("test_remove_file.txt")
     with open("test_remove_file.txt") as f:
         result = IO.remove_file("test_remove_file.txt")
         self.assertFalse(result)
     result = IO.remove_file("test_remove_file.txt")
     self.assertTrue(result)
Beispiel #2
0
    def test_remove_file(self):
        #Test file that doesn't exist
        result = IO.remove_file("sadksal21r45ewq90&&&&%%!@####:::")
        self.assertFalse(result)

        #Test file that does exist
        IO.ensfile("test_remove_file.exe")
        result = IO.remove_file("test_remove_file.exe")
        self.assertTrue(result)

        #Test file that exists, but can't be removed.
        IO.ensfile("test_remove_file.txt")
        with open("test_remove_file.txt") as f:
            result = IO.remove_file("test_remove_file.txt")
            self.assertFalse(result)
        result = IO.remove_file("test_remove_file.txt")
        self.assertTrue(result)
 def test_ensfile(self):
     #Test a bad filename
     filename = "!@#$%^&*():;[]{}.txt"
     with self.assertRaises(IOError):
         IO.ensfile(filename)
     
     import os, os.path
     #Make sure the folder isn't there
     path = "/test_ensdir_folder"
     filename = "/test_ensdir_folder/test_ensfile.txt"
     if os.path.isfile(filename): os.remove(filename)
     if os.path.isdir(path): os.rmdir(path)
     
     self.assertFalse(os.path.isfile(filename))
     IO.ensfile(filename)
     self.assertTrue(os.path.isfile(filename))
     os.remove(filename)
     os.rmdir(path)
Beispiel #4
0
    def test_ensfile(self):
        #Test a bad filename
        filename = "!@#$%^&*():;[]{}.txt"
        with self.assertRaises(IOError):
            IO.ensfile(filename)

        import os, os.path
        #Make sure the folder isn't there
        path = "/test_ensdir_folder"
        filename = "/test_ensdir_folder/test_ensfile.txt"
        if os.path.isfile(filename): os.remove(filename)
        if os.path.isdir(path): os.rmdir(path)

        self.assertFalse(os.path.isfile(filename))
        IO.ensfile(filename)
        self.assertTrue(os.path.isfile(filename))
        os.remove(filename)
        os.rmdir(path)