diff options
author | Joshua Harlow <harlowja@gmail.com> | 2016-05-11 14:18:02 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2016-05-11 14:18:02 -0700 |
commit | 26ea813d293467921ab6b1e32abd2ab8fcefa3bd (patch) | |
tree | bd641e5867bdd96effa33d62e5c200b5dd7e6331 /tests/unittests/test_datasource/test_cloudsigma.py | |
parent | 67e506a50dae2b0c1a806f482670b864e84809ae (diff) | |
download | vyos-cloud-init-26ea813d293467921ab6b1e32abd2ab8fcefa3bd.tar.gz vyos-cloud-init-26ea813d293467921ab6b1e32abd2ab8fcefa3bd.zip |
Fix py26 for rhel (and older versions of python)
Diffstat (limited to 'tests/unittests/test_datasource/test_cloudsigma.py')
-rw-r--r-- | tests/unittests/test_datasource/test_cloudsigma.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/tests/unittests/test_datasource/test_cloudsigma.py b/tests/unittests/test_datasource/test_cloudsigma.py index 772d189a..11968796 100644 --- a/tests/unittests/test_datasource/test_cloudsigma.py +++ b/tests/unittests/test_datasource/test_cloudsigma.py @@ -1,11 +1,18 @@ # coding: utf-8 + import copy -from cloudinit.cs_utils import Cepko -from cloudinit.sources import DataSourceCloudSigma +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 .. import helpers as test_helpers - +from ..helpers import SkipTest SERVER_CONTEXT = { "cpu": 1000, @@ -29,17 +36,20 @@ SERVER_CONTEXT = { } -class CepkoMock(Cepko): - def __init__(self, mocked_context): - self.result = mocked_context +if WILL_WORK: + 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) |