mock the which as it is used
-import os
-import stat
-
import mock
import platform
import six
import unittest
-
-from conans.client.tools import environment_append
-
-from conans.test.utils.test_files import temp_folder
from six import StringIO
from conans import tools
from conans.client.output import ConanOutput
from conans.client.tools.files import which
from conans.client.tools.oss import OSInfo
-from conans.client.tools.system_pm import ChocolateyTool, SystemPackageTool,\
- AptTool
+from conans.client.tools.system_pm import ChocolateyTool, SystemPackageTool, AptTool
from conans.errors import ConanException
from conans.test.unittests.util.tools_test import RunnerMock
-from conans.test.utils.tools import TestBufferConanOutput
from conans.test.utils.conanfile import MockSettings, MockConanfile
-from conans.util.files import save
+from conans.test.utils.tools import TestBufferConanOutput
class SystemPackageToolTest(unittest.TestCase):
@@ -157,12 +148,7 @@ class SystemPackageToolTest(unittest.TestCase):
spt.update()
self.assertEqual(runner.command_called, "sudo -A apt-get update")
- # Fake a dnf exe and check if for fedora it used it
- tmp = temp_folder()
- dnf_path = os.path.join(tmp, "dnf{}".format(".exe" if platform.system() == "Windows" else ".sh"))
- save(dnf_path, "fake_executable")
- os.chmod(dnf_path, stat.S_IEXEC)
- with environment_append({"PATH": tmp}):
+ with mock.patch("conans.client.tools.oss.which", return_value=True):
os_info.linux_distro = "fedora"
spt = SystemPackageTool(runner=runner, os_info=os_info, output=self.out)
spt.update()
