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=[])
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=[])
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")
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])