summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unittests/test_cs_util.py21
-rw-r--r--tests/unittests/test_datasource/test_cloudsigma.py23
-rw-r--r--tests/unittests/test_datasource/test_smartos.py15
3 files changed, 18 insertions, 41 deletions
diff --git a/tests/unittests/test_cs_util.py b/tests/unittests/test_cs_util.py
index 8c9ac0cd..56c9ce9e 100644
--- a/tests/unittests/test_cs_util.py
+++ b/tests/unittests/test_cs_util.py
@@ -2,13 +2,7 @@ from __future__ import print_function
from . import helpers as test_helpers
-import unittest2
-
-try:
- from cloudinit.cs_utils import Cepko
- WILL_WORK = True
-except ImportError:
- WILL_WORK = False
+from cloudinit.cs_utils import Cepko
SERVER_CONTEXT = {
@@ -26,13 +20,12 @@ SERVER_CONTEXT = {
}
-if WILL_WORK:
- class CepkoMock(Cepko):
- def all(self):
- return SERVER_CONTEXT
+class CepkoMock(Cepko):
+ def all(self):
+ return SERVER_CONTEXT
- def get(self, key="", request_pattern=None):
- return SERVER_CONTEXT['tags']
+ def get(self, key="", request_pattern=None):
+ return SERVER_CONTEXT['tags']
# 2015-01-22 BAW: This test is completely useless because it only ever tests
@@ -40,7 +33,7 @@ if WILL_WORK:
# touched the underlying Cepko class methods.
class CepkoResultTests(test_helpers.TestCase):
def setUp(self):
- raise unittest2.SkipTest('This test is completely useless')
+ raise test_helpers.SkipTest('This test is completely useless')
def test_getitem(self):
result = self.c.all()
diff --git a/tests/unittests/test_datasource/test_cloudsigma.py b/tests/unittests/test_datasource/test_cloudsigma.py
index 11968796..7950fc52 100644
--- a/tests/unittests/test_datasource/test_cloudsigma.py
+++ b/tests/unittests/test_datasource/test_cloudsigma.py
@@ -2,14 +2,8 @@
import copy
-try:
- # Serial does not work on py2.6 (anymore)
- import pyserial
- from cloudinit.cs_utils import Cepko
- from cloudinit.sources import DataSourceCloudSigma
- WILL_WORK = True
-except ImportError:
- WILL_WORK = False
+from cloudinit.cs_utils import Cepko
+from cloudinit.sources import DataSourceCloudSigma
from .. import helpers as test_helpers
from ..helpers import SkipTest
@@ -36,20 +30,17 @@ SERVER_CONTEXT = {
}
-if WILL_WORK:
- class CepkoMock(Cepko):
- def __init__(self, mocked_context):
- self.result = mocked_context
+class CepkoMock(Cepko):
+ def __init__(self, mocked_context):
+ self.result = mocked_context
- def all(self):
- return self
+ def all(self):
+ return self
class DataSourceCloudSigmaTest(test_helpers.TestCase):
def setUp(self):
super(DataSourceCloudSigmaTest, self).setUp()
- if not WILL_WORK:
- raise SkipTest("Datasource testing not supported")
self.datasource = DataSourceCloudSigma.DataSourceCloudSigma("", "", "")
self.datasource.is_running_in_cloudsigma = lambda: True
self.datasource.cepko = CepkoMock(SERVER_CONTEXT)
diff --git a/tests/unittests/test_datasource/test_smartos.py b/tests/unittests/test_datasource/test_smartos.py
index 6b628276..f536ef4f 100644
--- a/tests/unittests/test_datasource/test_smartos.py
+++ b/tests/unittests/test_datasource/test_smartos.py
@@ -33,13 +33,8 @@ import tempfile
import uuid
from binascii import crc32
-try:
- # Serial does not work on py2.6 (anymore)
- import serial
- from cloudinit.sources import DataSourceSmartOS
- WILL_WORK = True
-except ImportError:
- WILL_WORK = False
+from cloudinit import serial
+from cloudinit.sources import DataSourceSmartOS
import six
@@ -81,8 +76,7 @@ def get_mock_client(mockdata):
class TestSmartOSDataSource(helpers.FilesystemMockingTestCase):
def setUp(self):
super(TestSmartOSDataSource, self).setUp()
- if not WILL_WORK:
- raise SkipTest("This test will not work")
+
self.tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.tmp)
self.legacy_user_d = tempfile.mkdtemp()
@@ -448,8 +442,7 @@ class TestJoyentMetadataClient(helpers.FilesystemMockingTestCase):
def setUp(self):
super(TestJoyentMetadataClient, self).setUp()
- if not WILL_WORK:
- raise SkipTest("This test will not work")
+
self.serial = mock.MagicMock(spec=serial.Serial)
self.request_id = 0xabcdef12
self.metadata_value = 'value'