summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Watkins <oddbloke@ubuntu.com>2020-01-23 16:32:01 -0500
committerChad Smith <chad.smith@canonical.com>2020-01-23 14:32:01 -0700
commit6b157aa60a10fa74374287f0ec0313255e0462b4 (patch)
tree8d2e89cdde2cf3ca1450f7fd14f386639f838dc2
parent6603706eec1c39d9d591c8ffa0ef7171b74d84d6 (diff)
downloadvyos-cloud-init-6b157aa60a10fa74374287f0ec0313255e0462b4.tar.gz
vyos-cloud-init-6b157aa60a10fa74374287f0ec0313255e0462b4.zip
cloudinit: remove ImportError handling for mock imports (#182)
We only run on Python 3 now, so we can unambiguously expect unittest.mock to exist.
-rw-r--r--tests/unittests/test_data.py6
-rw-r--r--tests/unittests/test_distros/test_generic.py6
-rw-r--r--tests/unittests/test_distros/test_netconfig.py6
-rw-r--r--tests/unittests/test_handler/test_handler_apt_configure_sources_list_v1.py6
-rw-r--r--tests/unittests/test_handler/test_handler_apt_configure_sources_list_v3.py8
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source_v1.py8
-rw-r--r--tests/unittests/test_handler/test_handler_apt_source_v3.py9
-rw-r--r--tests/unittests/test_handler/test_handler_ca_certs.py5
-rw-r--r--tests/unittests/test_handler/test_handler_growpart.py5
-rw-r--r--tests/unittests/test_handler/test_handler_lxd.py5
-rw-r--r--tests/unittests/test_handler/test_handler_mounts.py6
-rw-r--r--tests/unittests/test_handler/test_handler_spacewalk.py6
-rw-r--r--tests/unittests/test_util.py6
13 files changed, 16 insertions, 66 deletions
diff --git a/tests/unittests/test_data.py b/tests/unittests/test_data.py
index e55feb22..c59db33d 100644
--- a/tests/unittests/test_data.py
+++ b/tests/unittests/test_data.py
@@ -5,11 +5,7 @@
import gzip
import logging
import os
-
-try:
- from unittest import mock
-except ImportError:
- import mock
+from unittest import mock
from six import BytesIO, StringIO
diff --git a/tests/unittests/test_distros/test_generic.py b/tests/unittests/test_distros/test_generic.py
index 7e0da4f2..02b334e3 100644
--- a/tests/unittests/test_distros/test_generic.py
+++ b/tests/unittests/test_distros/test_generic.py
@@ -8,11 +8,7 @@ from cloudinit.tests import helpers
import os
import shutil
import tempfile
-
-try:
- from unittest import mock
-except ImportError:
- import mock
+from unittest import mock
unknown_arch_info = {
'arches': ['default'],
diff --git a/tests/unittests/test_distros/test_netconfig.py b/tests/unittests/test_distros/test_netconfig.py
index aeaadaa0..5ede4d77 100644
--- a/tests/unittests/test_distros/test_netconfig.py
+++ b/tests/unittests/test_distros/test_netconfig.py
@@ -4,11 +4,7 @@ import copy
import os
from six import StringIO
from textwrap import dedent
-
-try:
- from unittest import mock
-except ImportError:
- import mock
+from unittest import mock
from cloudinit import distros
from cloudinit.distros.parsers.sys_conf import SysConf
diff --git a/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v1.py b/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v1.py
index 7c17a264..69009a44 100644
--- a/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v1.py
+++ b/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v1.py
@@ -7,11 +7,7 @@ import logging
import os
import shutil
import tempfile
-
-try:
- from unittest import mock
-except ImportError:
- import mock
+from unittest import mock
from cloudinit import cloud
from cloudinit import distros
diff --git a/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v3.py b/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v3.py
index 0a68cb8f..0aa3d51a 100644
--- a/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v3.py
+++ b/tests/unittests/test_handler/test_handler_apt_configure_sources_list_v3.py
@@ -7,12 +7,8 @@ import logging
import os
import shutil
import tempfile
-
-try:
- from unittest import mock
-except ImportError:
- import mock
-from mock import call
+from unittest import mock
+from unittest.mock import call
from cloudinit import cloud
from cloudinit import distros
diff --git a/tests/unittests/test_handler/test_handler_apt_source_v1.py b/tests/unittests/test_handler/test_handler_apt_source_v1.py
index 652d97ab..866752ef 100644
--- a/tests/unittests/test_handler/test_handler_apt_source_v1.py
+++ b/tests/unittests/test_handler/test_handler_apt_source_v1.py
@@ -9,12 +9,8 @@ import os
import re
import shutil
import tempfile
-
-try:
- from unittest import mock
-except ImportError:
- import mock
-from mock import call
+from unittest import mock
+from unittest.mock import call
from cloudinit.config import cc_apt_configure
from cloudinit import gpg
diff --git a/tests/unittests/test_handler/test_handler_apt_source_v3.py b/tests/unittests/test_handler/test_handler_apt_source_v3.py
index c5cf6785..90949b6d 100644
--- a/tests/unittests/test_handler/test_handler_apt_source_v3.py
+++ b/tests/unittests/test_handler/test_handler_apt_source_v3.py
@@ -11,13 +11,8 @@ import shutil
import socket
import tempfile
-from unittest import TestCase
-
-try:
- from unittest import mock
-except ImportError:
- import mock
-from mock import call
+from unittest import TestCase, mock
+from unittest.mock import call
from cloudinit import cloud
from cloudinit import distros
diff --git a/tests/unittests/test_handler/test_handler_ca_certs.py b/tests/unittests/test_handler/test_handler_ca_certs.py
index 06e14db0..5b4105dd 100644
--- a/tests/unittests/test_handler/test_handler_ca_certs.py
+++ b/tests/unittests/test_handler/test_handler_ca_certs.py
@@ -11,12 +11,9 @@ import logging
import shutil
import tempfile
import unittest
+from unittest import mock
try:
- from unittest import mock
-except ImportError:
- import mock
-try:
from contextlib import ExitStack
except ImportError:
from contextlib2 import ExitStack
diff --git a/tests/unittests/test_handler/test_handler_growpart.py b/tests/unittests/test_handler/test_handler_growpart.py
index 1f39ebe7..43b53745 100644
--- a/tests/unittests/test_handler/test_handler_growpart.py
+++ b/tests/unittests/test_handler/test_handler_growpart.py
@@ -11,12 +11,9 @@ import logging
import os
import re
import unittest
+from unittest import mock
try:
- from unittest import mock
-except ImportError:
- import mock
-try:
from contextlib import ExitStack
except ImportError:
from contextlib2 import ExitStack
diff --git a/tests/unittests/test_handler/test_handler_lxd.py b/tests/unittests/test_handler/test_handler_lxd.py
index b63db616..40b521e5 100644
--- a/tests/unittests/test_handler/test_handler_lxd.py
+++ b/tests/unittests/test_handler/test_handler_lxd.py
@@ -5,10 +5,7 @@ from cloudinit.sources import DataSourceNoCloud
from cloudinit import (distros, helpers, cloud)
from cloudinit.tests import helpers as t_help
-try:
- from unittest import mock
-except ImportError:
- import mock
+from unittest import mock
class TestLxd(t_help.CiTestCase):
diff --git a/tests/unittests/test_handler/test_handler_mounts.py b/tests/unittests/test_handler/test_handler_mounts.py
index 7bcefa0a..05ac183e 100644
--- a/tests/unittests/test_handler/test_handler_mounts.py
+++ b/tests/unittests/test_handler/test_handler_mounts.py
@@ -1,16 +1,12 @@
# This file is part of cloud-init. See LICENSE file for license information.
import os.path
+from unittest import mock
from cloudinit.config import cc_mounts
from cloudinit.tests import helpers as test_helpers
-try:
- from unittest import mock
-except ImportError:
- import mock
-
class TestSanitizeDevname(test_helpers.FilesystemMockingTestCase):
diff --git a/tests/unittests/test_handler/test_handler_spacewalk.py b/tests/unittests/test_handler/test_handler_spacewalk.py
index ddbf4a79..410e6f77 100644
--- a/tests/unittests/test_handler/test_handler_spacewalk.py
+++ b/tests/unittests/test_handler/test_handler_spacewalk.py
@@ -6,11 +6,7 @@ from cloudinit import util
from cloudinit.tests import helpers
import logging
-
-try:
- from unittest import mock
-except ImportError:
- import mock
+from unittest import mock
LOG = logging.getLogger(__name__)
diff --git a/tests/unittests/test_util.py b/tests/unittests/test_util.py
index 75a3f0b4..9ff17f52 100644
--- a/tests/unittests/test_util.py
+++ b/tests/unittests/test_util.py
@@ -12,15 +12,11 @@ import stat
import sys
import tempfile
import yaml
+from unittest import mock
from cloudinit import importer, util
from cloudinit.tests import helpers
-try:
- from unittest import mock
-except ImportError:
- import mock
-
BASH = util.which('bash')
BOGUS_COMMAND = 'this-is-not-expected-to-be-a-program-name'