示例#1
0
 def test_resolve_path_fail_4(self, mock_os):
     mock_os.path.abspath.return_value = "/tmp"
     mock_os.path.realpath.return_value = "/tmp"
     mock_os.path.isfile.return_value = False
     with self.assertRaises(OSError):
         # pylint: disable=W0212,protected-access
         util._resolve_path(".", dir_expected=False, permissions=[])
示例#2
0
 def test_resolve_path_fail_4(self, mock_os):
     mock_os.path.abspath.return_value = "/tmp"
     mock_os.path.realpath.return_value = "/tmp"
     mock_os.path.isfile.return_value = False
     with self.assertRaises(OSError):
         # pylint: disable=W0212,protected-access
         util._resolve_path(".", dir_expected=False, permissions=[])
示例#3
0
 def test_resolve_path_fail_6(self):
     # should fail when empty string or None are passed
     with self.assertRaises(ValueError):
         # pylint: disable=W0212,protected-access
         util._resolve_path(None, dir_expected=False, permissions=[])
         # pylint: enable=W0212,protected-access
     with self.assertRaises(ValueError):
         # pylint: disable=W0212,protected-access
         util._resolve_path("", dir_expected=False, permissions=[])
示例#4
0
 def test_resolve_path_fail_6(self):
     # should fail when empty string or None are passed
     with self.assertRaises(ValueError):
         # pylint: disable=W0212,protected-access
         util._resolve_path(None, dir_expected=False, permissions=[])
         # pylint: enable=W0212,protected-access
     with self.assertRaises(ValueError):
         # pylint: disable=W0212,protected-access
         util._resolve_path("", dir_expected=False, permissions=[])
示例#5
0
 def test_resolve_path_empty_permissions(self, mock_os):
     mock_os.path.abspath.return_value = "/tmp/a"
     mock_os.path.realpath.return_value = "/tmp/a/b"
     mock_os.path.isdir.return_value = True
     # pylint: disable=W0212,protected-access
     path = util._resolve_path(".", dir_expected=True, permissions=[])
     # pylint: enable=W0212,protected-access
     self.assertEqual(path, "/tmp/a/b")
示例#6
0
 def test_resolve_path_empty_permissions(self, mock_os):
     mock_os.path.abspath.return_value = "/tmp/a"
     mock_os.path.realpath.return_value = "/tmp/a/b"
     mock_os.path.isdir.return_value = True
     # pylint: disable=W0212,protected-access
     path = util._resolve_path(".", dir_expected=True, permissions=[])
     # pylint: enable=W0212,protected-access
     self.assertEqual(path, "/tmp/a/b")
示例#7
0
 def test_resolve_path_fail_2(self, mock_os):
     mock_os.path.abspath.return_value = "/tmp"
     mock_os.path.realpath.side_effect = OSError("Test")
     with self.assertRaises(OSError):
         # pylint: disable=W0212,protected-access
         util._resolve_path(".", True, [os.R_OK])
示例#8
0
 def test_resolve_path_fail_2(self, mock_os):
     mock_os.path.abspath.return_value = "/tmp"
     mock_os.path.realpath.side_effect = OSError("Test")
     with self.assertRaises(OSError):
         # pylint: disable=W0212,protected-access
         util._resolve_path(".", True, [os.R_OK])