Skip to content

Commit

Permalink
tests cleanup: Removes mock import checks
Browse files Browse the repository at this point in the history
In Python 3, the mock module is now part of the unittest module.
We no longer support Python 2, so there's no reason for the import checks.

Change-Id: I7b4d68cba4b587ad9f0121058ba615a9bb0aec93
  • Loading branch information
claudiubelu committed Jun 3, 2024
1 parent 00ece4b commit c01a7a7
Show file tree
Hide file tree
Showing 95 changed files with 96 additions and 461 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@

import sys
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.metadata.services.osconfigdrive import factory

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
import itertools
import os
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
Expand Down
5 changes: 1 addition & 4 deletions cloudbaseinit/tests/metadata/services/test_azureservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
import importlib
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
Expand Down
2 changes: 1 addition & 1 deletion cloudbaseinit/tests/metadata/services/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# License for the specific language governing permissions and limitations
# under the License.

import mock
import requests
import unittest
import unittest.mock as mock

from cloudbaseinit import exception
from cloudbaseinit.metadata.services import base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import importlib
import os
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import exception
from cloudbaseinit.metadata.services import baseconfigdrive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@
import functools
import posixpath
import unittest
import unittest.mock as mock

import netaddr

try:
import unittest.mock as mock
except ImportError:
import mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
from cloudbaseinit.metadata.services import base
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_cloudstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
import functools
import socket
import unittest
import unittest.mock as mock
import urllib

try:
import unittest.mock as mock
except ImportError:
import mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit.metadata.services import base
from cloudbaseinit.metadata.services import cloudstack
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_configdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@

import importlib
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.metadata.services import baseconfigdrive
from cloudbaseinit.tests import testutils
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_ec2service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit.metadata.services import ec2service
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_gceservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
import ddt
import importlib
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit.tests import testutils
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_httpservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@

import os
import unittest
import unittest.mock as mock
from urllib import error

try:
import unittest.mock as mock
except ImportError:
import mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit.metadata.services import base
from cloudbaseinit.metadata.services import httpservice
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_maasservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_nocloudservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import importlib
import os
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.metadata.services import base
from cloudbaseinit.models import network as nm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import re
import textwrap
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.metadata.services import base
from cloudbaseinit.metadata.services import opennebulaservice
Expand Down
5 changes: 1 addition & 4 deletions cloudbaseinit/tests/metadata/services/test_ovfservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import importlib
import os
import unittest
try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit.metadata.services import base
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/services/test_packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@

import importlib
import unittest
import unittest.mock as mock
from urllib import error

try:
import unittest.mock as mock
except ImportError:
import mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
from cloudbaseinit.tests import testutils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,15 @@

import importlib
import unittest
import unittest.mock as mock

import ddt

from cloudbaseinit.utils import serialization

try:
import unittest.mock as mock
except ImportError:
import mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
from cloudbaseinit.models import network as network_model
from cloudbaseinit.tests import testutils
from cloudbaseinit.utils import serialization


CONF = cloudbaseinit_conf.CONF
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/metadata/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import exception
from cloudbaseinit.metadata import factory
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/osutils/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@
import subprocess
import sys
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.osutils import base

Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/osutils/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@

import os
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.osutils import factory

Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/osutils/test_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@
import functools
import importlib
import os
import unittest.mock as mock

import netaddr

try:
import unittest.mock as mock
except ImportError:
import mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
from cloudbaseinit.tests import fake
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_createuser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit.plugins.common import base
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_ephemeraldisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import conf as cloudbaseinit_conf
from cloudbaseinit import exception
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_execcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
import os
import textwrap
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.plugins.common import base
from cloudbaseinit.plugins.common import execcmd
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_fileexecutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.plugins.common import fileexecutils
from cloudbaseinit.tests import testutils
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_localscripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@

import os
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.plugins.common import base
from cloudbaseinit.plugins.common import localscripts
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_mtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.plugins.common import base
from cloudbaseinit.plugins.common import mtu
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_networkconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@

import functools
import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit import exception
from cloudbaseinit.models import network as network_model
Expand Down
6 changes: 1 addition & 5 deletions cloudbaseinit/tests/plugins/common/test_ntpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
# under the License.

import unittest

try:
import unittest.mock as mock
except ImportError:
import mock
import unittest.mock as mock

from cloudbaseinit.plugins.common import base
from cloudbaseinit.plugins.common import ntpclient
Expand Down
Loading

0 comments on commit c01a7a7

Please sign in to comment.