Example #1
0
 def testWriteGoodFile(self):
     file = get_relative_path("testdata/new_file.txt")
     mode = "xt"
     try:
         self.assertIsNotNone(utils.openOrDie(file, mode))
     finally:
         os.remove(file)
Example #2
0
 def testPermissionErrorWrite(self):
     file = get_relative_path("testdata/existing_file.txt")
     mode = "wt"
     with mock.patch("builtins.open", mock.mock_open()) as mock_file:
         mock_file.side_effect = PermissionError()
         with self.assertRaises(SystemExit):
             utils.openOrDie(file, mode)
Example #3
0
 def testIsADirectoryError(self):
     file = get_relative_path("testdata")
     mode = "rt"
     with self.assertRaises(SystemExit):
         utils.openOrDie(file, mode)
Example #4
0
 def testFileNotFoundError(self):
     file = get_relative_path("testdata/nonexistentfile.txt")
     mode = "rt"
     with self.assertRaises(SystemExit):
         utils.openOrDie(file, mode)
Example #5
0
 def testFileExistsError(self):
     file = get_relative_path("testdata/existing_file.txt")
     mode = "xt"
     with self.assertRaises(SystemExit):
         utils.openOrDie(file, mode)
Example #6
0
 def testReadGoodFile(self):
     file = get_relative_path("testdata/existing_file.txt")
     mode = "rt"
     self.assertIsNotNone(utils.openOrDie(file, mode))
Example #7
0
def filePath(file_name):
    return os.path.abspath(testutils.get_relative_path(file_name))