diff options
author | Joshua Harlow <harlowja@gmail.com> | 2016-05-11 16:47:50 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2016-05-11 16:47:50 -0700 |
commit | 12d7ee2cb6589b866ab26b508b15c65326481d6c (patch) | |
tree | 397fb383c718d52929f70fc54402f865187120a4 /tests/unittests/test_datasource/test_cloudsigma.py | |
parent | e885f694c9951101b57ee182bebc000e398da563 (diff) | |
download | vyos-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_datasource/test_cloudsigma.py')
-rw-r--r-- | tests/unittests/test_datasource/test_cloudsigma.py | 23 |
1 files changed, 7 insertions, 16 deletions
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) |