leapp-repository/0042-Drop-dependency-on-mock.patch
Petr Stodulka c461aa328a IPU 9.9 -> 10.3: CTC1 candidate 1
- Introduce new upgrade path 9.9 -> 10.3
- Requires leapp-framework 6.5+
- Configure the net.naming-scheme when upgrading CS 9 to 10
- Fix scan of physical network interfaces and ethX detection
- Fix quoting in list representation of remediation commands
- Check PulseAudio configuration incompatible with PipeWire
- Consider RHUI source clients as signed by distribution vendor
- Ensure that greenboot packages are removed during the upgrade
- Fix AVC SELinux warnings caused by leapp execution
- Fix detection of network interfaces with biosdevname naming on Dell machines
- Fix failing upgrades with hugetlbfs file systems specified in FSTAB
- Fix the upgrade with LiveMode on systems with FIPS
- Introduce DISTRO_REPORT_NAMES in the distro library to provide unified names for linux distributions for the use in leapp reports
- Livemode: Fix the upgrade on systems where the generated live image is not in rootfs
- Modify keys for several reports that have been inconsistent between major releases. The keys are now independent of the used upgrade path
- Respect names of distributions used for the IPU in preupgrade reports
- Minor updates in reports
- Update leapp data files
- Resolves: RHEL-1771, RHEL-72140, RHEL-148291, RHEL-150278, RHEL-156902
2026-04-17 15:41:17 +02:00

150 lines
6.3 KiB
Diff

From 0f0be8e4ca80721173d289a3db0b170334529c2c Mon Sep 17 00:00:00 2001
From: Matej Matuska <mmatuska@redhat.com>
Date: Wed, 29 Oct 2025 19:31:00 +0100
Subject: [PATCH 42/44] Drop dependency on mock
The mock library is now a part of the Python standard library since
Python 3.3 and is available as the unittest.mock. The 'mock' library is
only a backport which is not needed anymore.
Also remove some unnecessary imports.
---
commands/tests/test_upgrade_paths.py | 2 +-
.../common/actors/biosdevname/tests/test_biosdevname.py | 3 ++-
.../actors/cephvolumescan/tests/test_cephvolumescan.py | 5 +----
.../tests/test_distributionsignedrpmscanner.py | 3 +--
.../actors/ifcfgscanner/tests/unit_test_ifcfgscanner.py | 2 +-
.../common/actors/scanmemory/tests/test_scanmemory.py | 3 ++-
.../tests/component_test_selinuxcontentscanner.py | 4 +---
.../el8toel9/actors/nisscanner/tests/test_nisscan.py | 3 ++-
requirements.txt | 1 -
9 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/commands/tests/test_upgrade_paths.py b/commands/tests/test_upgrade_paths.py
index 773cdf1c..83e8b7f9 100644
--- a/commands/tests/test_upgrade_paths.py
+++ b/commands/tests/test_upgrade_paths.py
@@ -1,7 +1,7 @@
import os
import resource
+import unittest.mock as mock
-import mock
import pytest
from leapp.cli.commands import command_utils
diff --git a/repos/system_upgrade/common/actors/biosdevname/tests/test_biosdevname.py b/repos/system_upgrade/common/actors/biosdevname/tests/test_biosdevname.py
index 3aa8c614..1b11174f 100644
--- a/repos/system_upgrade/common/actors/biosdevname/tests/test_biosdevname.py
+++ b/repos/system_upgrade/common/actors/biosdevname/tests/test_biosdevname.py
@@ -1,7 +1,8 @@
+from unittest.mock import mock_open, patch
+
import pytest
import pyudev
import six
-from mock import mock_open, patch
from leapp.exceptions import StopActorExecutionError
from leapp.libraries.actor import biosdevname
diff --git a/repos/system_upgrade/common/actors/cephvolumescan/tests/test_cephvolumescan.py b/repos/system_upgrade/common/actors/cephvolumescan/tests/test_cephvolumescan.py
index 168b8fc2..14e1f359 100644
--- a/repos/system_upgrade/common/actors/cephvolumescan/tests/test_cephvolumescan.py
+++ b/repos/system_upgrade/common/actors/cephvolumescan/tests/test_cephvolumescan.py
@@ -1,9 +1,6 @@
-import pytest
-from mock import Mock, patch
+from unittest.mock import patch
from leapp.libraries.actor import cephvolumescan
-from leapp.models import InstalledRPM, LsblkEntry, RPM, StorageInfo
-from leapp.reporting import Report
CONT_PS_COMMAND_OUTPUT = {
"stdout":
diff --git a/repos/system_upgrade/common/actors/distributionsignedrpmscanner/tests/test_distributionsignedrpmscanner.py b/repos/system_upgrade/common/actors/distributionsignedrpmscanner/tests/test_distributionsignedrpmscanner.py
index b0c616cb..e5db0c8f 100644
--- a/repos/system_upgrade/common/actors/distributionsignedrpmscanner/tests/test_distributionsignedrpmscanner.py
+++ b/repos/system_upgrade/common/actors/distributionsignedrpmscanner/tests/test_distributionsignedrpmscanner.py
@@ -1,4 +1,4 @@
-import mock
+import unittest.mock as mock
from leapp.libraries.common import rpms
from leapp.libraries.common.config import mock_configs
@@ -8,7 +8,6 @@ from leapp.models import (
fields,
InstalledRPM,
InstalledUnsignedRPM,
- IPUConfig,
Model,
OSRelease,
RPM,
diff --git a/repos/system_upgrade/common/actors/ifcfgscanner/tests/unit_test_ifcfgscanner.py b/repos/system_upgrade/common/actors/ifcfgscanner/tests/unit_test_ifcfgscanner.py
index d996de84..bef3d485 100644
--- a/repos/system_upgrade/common/actors/ifcfgscanner/tests/unit_test_ifcfgscanner.py
+++ b/repos/system_upgrade/common/actors/ifcfgscanner/tests/unit_test_ifcfgscanner.py
@@ -1,9 +1,9 @@
import errno
import textwrap
+import unittest.mock as mock
from io import StringIO
from os.path import basename
-import mock
import six
from leapp.libraries.actor import ifcfgscanner
diff --git a/repos/system_upgrade/common/actors/scanmemory/tests/test_scanmemory.py b/repos/system_upgrade/common/actors/scanmemory/tests/test_scanmemory.py
index 13e4e724..20fa8e91 100644
--- a/repos/system_upgrade/common/actors/scanmemory/tests/test_scanmemory.py
+++ b/repos/system_upgrade/common/actors/scanmemory/tests/test_scanmemory.py
@@ -1,4 +1,5 @@
-import mock
+import unittest.mock as mock
+
import six
from leapp.libraries.actor import scanmemory
diff --git a/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/component_test_selinuxcontentscanner.py b/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/component_test_selinuxcontentscanner.py
index 802e038a..15aef5d8 100644
--- a/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/component_test_selinuxcontentscanner.py
+++ b/repos/system_upgrade/common/actors/selinux/selinuxcontentscanner/tests/component_test_selinuxcontentscanner.py
@@ -4,9 +4,7 @@ import pytest
from leapp.libraries.common.config import mock_configs
from leapp.libraries.stdlib import api, CalledProcessError, run
-from leapp.models import SELinuxCustom, SELinuxFacts, SELinuxModule, SELinuxModules, SELinuxRequestRPMs
-from leapp.reporting import Report
-from leapp.snactor.fixture import current_actor_context
+from leapp.models import SELinuxCustom, SELinuxFacts, SELinuxModules, SELinuxRequestRPMs
# compat module ensures compatibility with newer systems and is not part of testing
TEST_MODULES = [
diff --git a/repos/system_upgrade/el8toel9/actors/nisscanner/tests/test_nisscan.py b/repos/system_upgrade/el8toel9/actors/nisscanner/tests/test_nisscan.py
index ed000ce0..d7e77a28 100644
--- a/repos/system_upgrade/el8toel9/actors/nisscanner/tests/test_nisscan.py
+++ b/repos/system_upgrade/el8toel9/actors/nisscanner/tests/test_nisscan.py
@@ -1,4 +1,5 @@
-import mock
+import unittest.mock as mock
+
import pytest
import six
diff --git a/requirements.txt b/requirements.txt
index e4294718..ee1d9006 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,6 @@
flake8
isort
funcsigs==1.0.2
-mock==2.0.0
pylint
pytest==6.2.5; python_version >= '3.6' and python_version < '3.8'
pytest==7.4.4; python_version >= '3.8' and python_version < '3.10'
--
2.53.0