Esempio n. 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)
Esempio n. 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)
Esempio n. 3
0
 def testIsADirectoryError(self):
     file = get_relative_path("testdata")
     mode = "rt"
     with self.assertRaises(SystemExit):
         utils.openOrDie(file, mode)
Esempio n. 4
0
 def testFileNotFoundError(self):
     file = get_relative_path("testdata/nonexistentfile.txt")
     mode = "rt"
     with self.assertRaises(SystemExit):
         utils.openOrDie(file, mode)
Esempio n. 5
0
 def testFileExistsError(self):
     file = get_relative_path("testdata/existing_file.txt")
     mode = "xt"
     with self.assertRaises(SystemExit):
         utils.openOrDie(file, mode)
Esempio n. 6
0
 def testReadGoodFile(self):
     file = get_relative_path("testdata/existing_file.txt")
     mode = "rt"
     self.assertIsNotNone(utils.openOrDie(file, mode))
Esempio n. 7
0
def filePath(file_name):
    return os.path.abspath(testutils.get_relative_path(file_name))