Exemplo n.º 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=[])
Exemplo n.º 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=[])
Exemplo n.º 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=[])
Exemplo n.º 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=[])
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 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])
Exemplo n.º 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])