neil / rpms / python-blivet

Forked from rpms/python-blivet a year ago
Clone

Blame SOURCES/0005-Fix-unify-importing-mock-module-in-tests.patch

5c7b2d
From ad34dfa2f983bb3159af8b5780193e0427b505e9 Mon Sep 17 00:00:00 2001
5c7b2d
From: Vojtech Trefny <vtrefny@redhat.com>
5c7b2d
Date: Thu, 10 Jun 2021 15:01:26 +0200
5c7b2d
Subject: [PATCH] Fix/unify importing mock module in tests
5c7b2d
5c7b2d
mock is available in the unittest module since Python 3.3, we need
5c7b2d
to use the old mock module not only with Python 2 but also with
5c7b2d
the early versions of Python 3.
5c7b2d
---
5c7b2d
 tests/action_test.py                         |  5 ++-
5c7b2d
 tests/dbus_test.py                           |  9 +++--
5c7b2d
 tests/devicefactory_test.py                  |  6 ++--
5c7b2d
 tests/devicelibs_test/disk_test.py           |  6 ++--
5c7b2d
 tests/devicelibs_test/edd_test.py            |  6 +++-
5c7b2d
 tests/devices_test/dependencies_test.py      |  6 ++--
5c7b2d
 tests/devices_test/device_methods_test.py    |  8 +++--
5c7b2d
 tests/devices_test/device_names_test.py      |  6 ++--
5c7b2d
 tests/devices_test/device_properties_test.py |  8 ++---
5c7b2d
 tests/devices_test/disk_test.py              |  7 ++--
5c7b2d
 tests/devices_test/lvm_test.py               |  7 ++--
5c7b2d
 tests/devices_test/partition_test.py         |  6 ++--
5c7b2d
 tests/devices_test/tags_test.py              |  6 ++--
5c7b2d
 tests/devicetree_test.py                     |  6 ++--
5c7b2d
 tests/events_test.py                         |  6 ++--
5c7b2d
 tests/formats_test/disklabel_test.py         |  6 ++--
5c7b2d
 tests/formats_test/luks_test.py              |  6 ++--
5c7b2d
 tests/formats_test/lvmpv_test.py             |  2 --
5c7b2d
 tests/formats_test/methods_test.py           |  6 ++--
5c7b2d
 tests/formats_test/selinux_test.py           |  6 ++--
5c7b2d
 tests/formats_test/swap_test.py              |  2 --
5c7b2d
 tests/misc_test.py                           |  6 ++--
5c7b2d
 tests/partitioning_test.py                   |  6 ++--
5c7b2d
 tests/populator_test.py                      |  6 ++--
5c7b2d
 tests/storagetestcase.py                     |  5 ++-
5c7b2d
 tests/test_compat.py                         | 38 --------------------
5c7b2d
 tests/udev_test.py                           |  6 +++-
5c7b2d
 tests/unsupported_disklabel_test.py          |  7 ++--
5c7b2d
 tests/util_test.py                           |  6 ++--
5c7b2d
 29 files changed, 104 insertions(+), 102 deletions(-)
5c7b2d
 delete mode 100644 tests/test_compat.py
5c7b2d
5c7b2d
diff --git a/tests/action_test.py b/tests/action_test.py
5c7b2d
index 38a2e872..f60cf5d7 100644
5c7b2d
--- a/tests/action_test.py
5c7b2d
+++ b/tests/action_test.py
5c7b2d
@@ -1,9 +1,8 @@
5c7b2d
-from six import PY3
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
-if PY3:
5c7b2d
+try:
5c7b2d
     from unittest.mock import Mock
5c7b2d
-else:
5c7b2d
+except ImportError:
5c7b2d
     from mock import Mock
5c7b2d
 
5c7b2d
 from tests.storagetestcase import StorageTestCase
5c7b2d
diff --git a/tests/dbus_test.py b/tests/dbus_test.py
5c7b2d
index 293ac073..9bb9102a 100644
5c7b2d
--- a/tests/dbus_test.py
5c7b2d
+++ b/tests/dbus_test.py
5c7b2d
@@ -1,7 +1,10 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
-
5c7b2d
 import random
5c7b2d
-from six.moves.mock import Mock, patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
+
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, Mock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, Mock
5c7b2d
+
5c7b2d
 from unittest import TestCase
5c7b2d
 
5c7b2d
 import dbus
5c7b2d
diff --git a/tests/devicefactory_test.py b/tests/devicefactory_test.py
5c7b2d
index dc0d6408..93c8bdb7 100644
5c7b2d
--- a/tests/devicefactory_test.py
5c7b2d
+++ b/tests/devicefactory_test.py
5c7b2d
@@ -4,8 +4,10 @@ import unittest
5c7b2d
 from decimal import Decimal
5c7b2d
 import os
5c7b2d
 
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
-from six.moves.mock import patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch
5c7b2d
 
5c7b2d
 import blivet
5c7b2d
 
5c7b2d
diff --git a/tests/devicelibs_test/disk_test.py b/tests/devicelibs_test/disk_test.py
5c7b2d
index e67ef5b1..9cb39951 100644
5c7b2d
--- a/tests/devicelibs_test/disk_test.py
5c7b2d
+++ b/tests/devicelibs_test/disk_test.py
5c7b2d
@@ -1,8 +1,10 @@
5c7b2d
 # pylint: skip-file
5c7b2d
-import test_compat
5c7b2d
+try:
5c7b2d
+    from unittest.mock import Mock, patch, sentinel
5c7b2d
+except ImportError:
5c7b2d
+    from mock import Mock, patch, sentinel
5c7b2d
 
5c7b2d
 import six
5c7b2d
-from six.moves.mock import Mock, patch, sentinel
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
 from blivet.devicelibs import disk as disklib
5c7b2d
diff --git a/tests/devicelibs_test/edd_test.py b/tests/devicelibs_test/edd_test.py
5c7b2d
index 23d736f4..21bbcffc 100644
5c7b2d
--- a/tests/devicelibs_test/edd_test.py
5c7b2d
+++ b/tests/devicelibs_test/edd_test.py
5c7b2d
@@ -1,5 +1,9 @@
5c7b2d
+try:
5c7b2d
+    from unittest import mock
5c7b2d
+except ImportError:
5c7b2d
+    import mock
5c7b2d
+
5c7b2d
 import unittest
5c7b2d
-import mock
5c7b2d
 import os
5c7b2d
 import inspect
5c7b2d
 import logging
5c7b2d
diff --git a/tests/devices_test/dependencies_test.py b/tests/devices_test/dependencies_test.py
5c7b2d
index c012751d..493d1c9f 100644
5c7b2d
--- a/tests/devices_test/dependencies_test.py
5c7b2d
+++ b/tests/devices_test/dependencies_test.py
5c7b2d
@@ -1,8 +1,6 @@
5c7b2d
-# vim:set fileencoding=utf-8
5c7b2d
-from six import PY3
5c7b2d
-if PY3:
5c7b2d
+try:
5c7b2d
     from unittest.mock import patch, PropertyMock
5c7b2d
-else:
5c7b2d
+except ImportError:
5c7b2d
     from mock import patch, PropertyMock
5c7b2d
 
5c7b2d
 import unittest
5c7b2d
diff --git a/tests/devices_test/device_methods_test.py b/tests/devices_test/device_methods_test.py
5c7b2d
index f00509be..8a70b5bb 100644
5c7b2d
--- a/tests/devices_test/device_methods_test.py
5c7b2d
+++ b/tests/devices_test/device_methods_test.py
5c7b2d
@@ -1,9 +1,11 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
-
5c7b2d
 import six
5c7b2d
-from six.moves.mock import patch, Mock, PropertyMock  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, Mock, PropertyMock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, PropertyMock
5c7b2d
+
5c7b2d
 from blivet.devices import StorageDevice
5c7b2d
 from blivet.devices import DiskDevice, PartitionDevice
5c7b2d
 from blivet.devices import LVMVolumeGroupDevice, LVMLogicalVolumeDevice
5c7b2d
diff --git a/tests/devices_test/device_names_test.py b/tests/devices_test/device_names_test.py
5c7b2d
index 2a66f983..ca44d38c 100644
5c7b2d
--- a/tests/devices_test/device_names_test.py
5c7b2d
+++ b/tests/devices_test/device_names_test.py
5c7b2d
@@ -1,7 +1,9 @@
5c7b2d
 # vim:set fileencoding=utf-8
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch
5c7b2d
 
5c7b2d
-from six.moves.mock import patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import six
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
diff --git a/tests/devices_test/device_properties_test.py b/tests/devices_test/device_properties_test.py
5c7b2d
index 240ac088..8928707f 100644
5c7b2d
--- a/tests/devices_test/device_properties_test.py
5c7b2d
+++ b/tests/devices_test/device_properties_test.py
5c7b2d
@@ -1,6 +1,3 @@
5c7b2d
-# vim:set fileencoding=utf-8
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
-
5c7b2d
 import six
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
@@ -9,7 +6,10 @@ gi.require_version("BlockDev", "2.0")
5c7b2d
 
5c7b2d
 from gi.repository import BlockDev as blockdev
5c7b2d
 
5c7b2d
-from six.moves.mock import Mock, patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, Mock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, Mock
5c7b2d
 
5c7b2d
 import blivet
5c7b2d
 
5c7b2d
diff --git a/tests/devices_test/disk_test.py b/tests/devices_test/disk_test.py
5c7b2d
index e9852303..cc8454e1 100644
5c7b2d
--- a/tests/devices_test/disk_test.py
5c7b2d
+++ b/tests/devices_test/disk_test.py
5c7b2d
@@ -1,7 +1,8 @@
5c7b2d
 # pylint: skip-file
5c7b2d
-import test_compat
5c7b2d
-
5c7b2d
-from six.moves.mock import patch
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
 from blivet.devices import DiskDevice
5c7b2d
diff --git a/tests/devices_test/lvm_test.py b/tests/devices_test/lvm_test.py
5c7b2d
index 670c91c9..f50933c4 100644
5c7b2d
--- a/tests/devices_test/lvm_test.py
5c7b2d
+++ b/tests/devices_test/lvm_test.py
5c7b2d
@@ -1,8 +1,9 @@
5c7b2d
-# vim:set fileencoding=utf-8
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, PropertyMock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, PropertyMock
5c7b2d
 
5c7b2d
 import six
5c7b2d
-from six.moves.mock import patch, PropertyMock  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
 import blivet
5c7b2d
diff --git a/tests/devices_test/partition_test.py b/tests/devices_test/partition_test.py
5c7b2d
index 0abd88df..4748dafe 100644
5c7b2d
--- a/tests/devices_test/partition_test.py
5c7b2d
+++ b/tests/devices_test/partition_test.py
5c7b2d
@@ -1,5 +1,4 @@
5c7b2d
 # vim:set fileencoding=utf-8
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
 
5c7b2d
 from collections import namedtuple
5c7b2d
 import os
5c7b2d
@@ -7,7 +6,10 @@ import six
5c7b2d
 import unittest
5c7b2d
 import parted
5c7b2d
 
5c7b2d
-from six.moves.mock import Mock, patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, Mock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, Mock
5c7b2d
 
5c7b2d
 from blivet.devices import DiskFile
5c7b2d
 from blivet.devices import PartitionDevice
5c7b2d
diff --git a/tests/devices_test/tags_test.py b/tests/devices_test/tags_test.py
5c7b2d
index 1edc37f6..49a2d72e 100644
5c7b2d
--- a/tests/devices_test/tags_test.py
5c7b2d
+++ b/tests/devices_test/tags_test.py
5c7b2d
@@ -1,6 +1,8 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch
5c7b2d
 
5c7b2d
-from six.moves.mock import patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
 from blivet.devices import DiskDevice, FcoeDiskDevice, iScsiDiskDevice, MultipathDevice, StorageDevice, ZFCPDiskDevice
5c7b2d
diff --git a/tests/devicetree_test.py b/tests/devicetree_test.py
5c7b2d
index 11f8469d..fbf31c77 100644
5c7b2d
--- a/tests/devicetree_test.py
5c7b2d
+++ b/tests/devicetree_test.py
5c7b2d
@@ -1,6 +1,8 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, Mock, PropertyMock, sentinel
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, Mock, PropertyMock, sentinel
5c7b2d
 
5c7b2d
-from six.moves.mock import Mock, patch, PropertyMock, sentinel  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import os
5c7b2d
 import six
5c7b2d
 import unittest
5c7b2d
diff --git a/tests/events_test.py b/tests/events_test.py
5c7b2d
index 5906b4e2..22666f6d 100644
5c7b2d
--- a/tests/events_test.py
5c7b2d
+++ b/tests/events_test.py
5c7b2d
@@ -1,6 +1,8 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, Mock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, Mock
5c7b2d
 
5c7b2d
-from six.moves.mock import Mock, patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import time
5c7b2d
 from unittest import TestCase
5c7b2d
 
5c7b2d
diff --git a/tests/formats_test/disklabel_test.py b/tests/formats_test/disklabel_test.py
5c7b2d
index 0cfa736d..f514a778 100644
5c7b2d
--- a/tests/formats_test/disklabel_test.py
5c7b2d
+++ b/tests/formats_test/disklabel_test.py
5c7b2d
@@ -1,7 +1,9 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest import mock
5c7b2d
+except ImportError:
5c7b2d
+    import mock
5c7b2d
 
5c7b2d
 import parted
5c7b2d
-from six.moves import mock  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
 import blivet
5c7b2d
diff --git a/tests/formats_test/luks_test.py b/tests/formats_test/luks_test.py
5c7b2d
index be0d50b0..1edbdcb2 100644
5c7b2d
--- a/tests/formats_test/luks_test.py
5c7b2d
+++ b/tests/formats_test/luks_test.py
5c7b2d
@@ -1,6 +1,8 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch
5c7b2d
 
5c7b2d
-from six.moves.mock import patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
 from blivet.formats.luks import LUKS
5c7b2d
diff --git a/tests/formats_test/lvmpv_test.py b/tests/formats_test/lvmpv_test.py
5c7b2d
index 792a2f1d..cbd2c419 100644
5c7b2d
--- a/tests/formats_test/lvmpv_test.py
5c7b2d
+++ b/tests/formats_test/lvmpv_test.py
5c7b2d
@@ -1,5 +1,3 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
-
5c7b2d
 from blivet.formats.lvmpv import LVMPhysicalVolume
5c7b2d
 
5c7b2d
 from blivet.size import Size
5c7b2d
diff --git a/tests/formats_test/methods_test.py b/tests/formats_test/methods_test.py
5c7b2d
index b2674ea7..2743b7db 100644
5c7b2d
--- a/tests/formats_test/methods_test.py
5c7b2d
+++ b/tests/formats_test/methods_test.py
5c7b2d
@@ -1,7 +1,9 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, sentinel, PropertyMock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, sentinel, PropertyMock
5c7b2d
 
5c7b2d
 import six
5c7b2d
-from six.moves.mock import patch, sentinel, PropertyMock  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
 from blivet.errors import DeviceFormatError
5c7b2d
diff --git a/tests/formats_test/selinux_test.py b/tests/formats_test/selinux_test.py
5c7b2d
index 02e39011..26df5fe9 100644
5c7b2d
--- a/tests/formats_test/selinux_test.py
5c7b2d
+++ b/tests/formats_test/selinux_test.py
5c7b2d
@@ -1,9 +1,9 @@
5c7b2d
 # pylint: disable=unused-import
5c7b2d
 import os
5c7b2d
-from six import PY3
5c7b2d
-if PY3:
5c7b2d
+
5c7b2d
+try:
5c7b2d
     from unittest.mock import patch, ANY
5c7b2d
-else:
5c7b2d
+except ImportError:
5c7b2d
     from mock import patch, ANY
5c7b2d
 
5c7b2d
 import unittest
5c7b2d
diff --git a/tests/formats_test/swap_test.py b/tests/formats_test/swap_test.py
5c7b2d
index 56356144..8968ca15 100644
5c7b2d
--- a/tests/formats_test/swap_test.py
5c7b2d
+++ b/tests/formats_test/swap_test.py
5c7b2d
@@ -1,5 +1,3 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
-
5c7b2d
 import six
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
diff --git a/tests/misc_test.py b/tests/misc_test.py
5c7b2d
index 3c8cf344..10ea1320 100644
5c7b2d
--- a/tests/misc_test.py
5c7b2d
+++ b/tests/misc_test.py
5c7b2d
@@ -1,7 +1,9 @@
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
-from six.moves.mock import patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch
5c7b2d
 
5c7b2d
 import blivet
5c7b2d
 
5c7b2d
diff --git a/tests/partitioning_test.py b/tests/partitioning_test.py
5c7b2d
index b7aa5045..9b27f0c0 100644
5c7b2d
--- a/tests/partitioning_test.py
5c7b2d
+++ b/tests/partitioning_test.py
5c7b2d
@@ -1,6 +1,8 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, Mock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, Mock
5c7b2d
 
5c7b2d
-from six.moves.mock import Mock, patch  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import six
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
diff --git a/tests/populator_test.py b/tests/populator_test.py
5c7b2d
index a7748a9d..2a8532f0 100644
5c7b2d
--- a/tests/populator_test.py
5c7b2d
+++ b/tests/populator_test.py
5c7b2d
@@ -1,7 +1,9 @@
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import call, patch, sentinel, Mock, PropertyMock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import call, patch, sentinel, Mock, PropertyMock
5c7b2d
 
5c7b2d
 import gi
5c7b2d
-from six.moves.mock import call, patch, sentinel, Mock, PropertyMock  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import six
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
diff --git a/tests/storagetestcase.py b/tests/storagetestcase.py
5c7b2d
index 1844dec5..1b856914 100644
5c7b2d
--- a/tests/storagetestcase.py
5c7b2d
+++ b/tests/storagetestcase.py
5c7b2d
@@ -1,6 +1,9 @@
5c7b2d
 
5c7b2d
 import unittest
5c7b2d
-from mock import Mock
5c7b2d
+try:
5c7b2d
+    from unittest.mock import Mock
5c7b2d
+except ImportError:
5c7b2d
+    from mock import Mock
5c7b2d
 
5c7b2d
 import parted
5c7b2d
 
5c7b2d
diff --git a/tests/test_compat.py b/tests/test_compat.py
5c7b2d
deleted file mode 100644
5c7b2d
index d0859e24..00000000
5c7b2d
--- a/tests/test_compat.py
5c7b2d
+++ /dev/null
5c7b2d
@@ -1,38 +0,0 @@
5c7b2d
-# test_compat.py
5c7b2d
-# Python (2 -v- 3) compatibility functions.
5c7b2d
-#
5c7b2d
-# Copyright (C) 2017  Red Hat, Inc.
5c7b2d
-#
5c7b2d
-# This copyrighted material is made available to anyone wishing to use,
5c7b2d
-# modify, copy, or redistribute it subject to the terms and conditions of
5c7b2d
-# the GNU Lesser General Public License v.2, or (at your option) any later
5c7b2d
-# version. This program is distributed in the hope that it will be useful,
5c7b2d
-# but WITHOUT ANY WARRANTY expressed or implied, including the implied
5c7b2d
-# warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
5c7b2d
-# the GNU Lesser General Public License for more details.  You should have
5c7b2d
-# received a copy of the GNU Lesser General Public License along with this
5c7b2d
-# program; if not, write to the Free Software Foundation, Inc., 51 Franklin
5c7b2d
-# Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat trademarks
5c7b2d
-# that are incorporated in the source code or documentation are not subject
5c7b2d
-# to the GNU Lesser General Public License and may only be used or
5c7b2d
-# replicated with the express permission of Red Hat, Inc.
5c7b2d
-#
5c7b2d
-# Red Hat Author(s): David Lehman <dlehman@redhat.com>
5c7b2d
-#
5c7b2d
-
5c7b2d
-import six as _six
5c7b2d
-
5c7b2d
-mock_move = _six.MovedModule('mock', 'mock', 'unittest.mock')
5c7b2d
-
5c7b2d
-
5c7b2d
-def add_move(mod):
5c7b2d
-    _six.add_move(mod)
5c7b2d
-    # https://bitbucket.org/gutworth/six/issues/116/enable-importing-from-within-custom
5c7b2d
-    _six._importer._add_module(mod, "moves." + mod.name)
5c7b2d
-
5c7b2d
-
5c7b2d
-def setup():
5c7b2d
-    add_move(mock_move)
5c7b2d
-
5c7b2d
-
5c7b2d
-setup()
5c7b2d
diff --git a/tests/udev_test.py b/tests/udev_test.py
5c7b2d
index f9b10620..569a144e 100644
5c7b2d
--- a/tests/udev_test.py
5c7b2d
+++ b/tests/udev_test.py
5c7b2d
@@ -1,6 +1,10 @@
5c7b2d
 
5c7b2d
 import unittest
5c7b2d
-import mock
5c7b2d
+
5c7b2d
+try:
5c7b2d
+    from unittest import mock
5c7b2d
+except ImportError:
5c7b2d
+    import mock
5c7b2d
 
5c7b2d
 from udev_data import raid_data
5c7b2d
 
5c7b2d
diff --git a/tests/unsupported_disklabel_test.py b/tests/unsupported_disklabel_test.py
5c7b2d
index f5b24779..38055333 100644
5c7b2d
--- a/tests/unsupported_disklabel_test.py
5c7b2d
+++ b/tests/unsupported_disklabel_test.py
5c7b2d
@@ -1,7 +1,8 @@
5c7b2d
-# vim:set fileencoding=utf-8
5c7b2d
-import test_compat  # pylint: disable=unused-import
5c7b2d
+try:
5c7b2d
+    from unittest.mock import patch, sentinel, DEFAULT
5c7b2d
+except ImportError:
5c7b2d
+    from mock import patch, sentinel, DEFAULT
5c7b2d
 
5c7b2d
-from six.moves.mock import patch, sentinel, DEFAULT  # pylint: disable=no-name-in-module,import-error
5c7b2d
 import six
5c7b2d
 import unittest
5c7b2d
 
5c7b2d
diff --git a/tests/util_test.py b/tests/util_test.py
5c7b2d
index 853b6166..b4f82c1b 100644
5c7b2d
--- a/tests/util_test.py
5c7b2d
+++ b/tests/util_test.py
5c7b2d
@@ -1,7 +1,9 @@
5c7b2d
 # pylint: skip-file
5c7b2d
-import test_compat
5c7b2d
+try:
5c7b2d
+    from unittest import mock
5c7b2d
+except ImportError:
5c7b2d
+    import mock
5c7b2d
 
5c7b2d
-from six.moves import mock
5c7b2d
 import os
5c7b2d
 import six
5c7b2d
 import tempfile
5c7b2d
-- 
5c7b2d
2.31.1
5c7b2d