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