summaryrefslogtreecommitdiff
path: root/tests/unittests/test_cs_util.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2016-05-11 16:47:50 -0700
committerJoshua Harlow <harlowja@gmail.com>2016-05-11 16:47:50 -0700
commit12d7ee2cb6589b866ab26b508b15c65326481d6c (patch)
tree397fb383c718d52929f70fc54402f865187120a4 /tests/unittests/test_cs_util.py
parente885f694c9951101b57ee182bebc000e398da563 (diff)
downloadvyos-cloud-init-12d7ee2cb6589b866ab26b508b15c65326481d6c.tar.gz
vyos-cloud-init-12d7ee2cb6589b866ab26b508b15c65326481d6c.zip
Use a fake serial module that will allow tests to contine
Instead of aborting all serial using tests instead just create a serial module in cloudinit that will create a fake and broken serial class when pyserial is not actually installed. This allows for using the datasource and tests that exist in a more functional and tested manner (even when pyserial is not found).
Diffstat (limited to 'tests/unittests/test_cs_util.py')
-rw-r--r--tests/unittests/test_cs_util.py21
1 files changed, 7 insertions, 14 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()