def test_system_without_sudo(self): with mock.patch("os.path.isfile", return_value=False): self.assertFalse(SystemPackageTool._is_sudo_enabled()) self.assertEqual(SystemPackageTool._get_sudo_str(), "") with mock.patch("sys.stdout.isatty", return_value=True): self.assertEqual(SystemPackageTool._get_sudo_str(), "")
def test_sudo_tty(self): with tools.environment_append({"CONAN_SYSREQUIRES_SUDO": "False"}): self.assertFalse(SystemPackageTool._is_sudo_enabled()) self.assertEqual(SystemPackageTool._get_sudo_str(), "") with tools.environment_append({"CONAN_SYSREQUIRES_SUDO": "True"}): self.assertTrue(SystemPackageTool._is_sudo_enabled()) self.assertEqual(SystemPackageTool._get_sudo_str(), "sudo -A ") with mock.patch("sys.stdout.isatty", return_value=True): self.assertEqual(SystemPackageTool._get_sudo_str(), "sudo ")