From 33dc22c4b2309ae51f4311f7029979b72be43c60 Mon Sep 17 00:00:00 2001 From: Oskari Saarenmaa Date: Thu, 15 Jan 2015 23:55:57 +0200 Subject: [PATCH] tests: don't test git or aws if required modules are too old or not installed --- poni/cloud_aws.py | 4 +++- tests/test_cloud_aws_comparison.py | 5 ++++- tests/test_vc.py | 10 ++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/poni/cloud_aws.py b/poni/cloud_aws.py index 8af5a1f..1d5dcb1 100644 --- a/poni/cloud_aws.py +++ b/poni/cloud_aws.py @@ -38,8 +38,10 @@ import boto.ec2.blockdevicemapping import boto.exception import boto.vpc + boto_is_current = LooseVersion(boto.Version) >= BOTO_REQUIREMENT except ImportError: boto = None + boto_is_current = False def convert_boto_errors(method): @@ -314,7 +316,7 @@ def get_provider_key(cls, cloud_prop): def __init__(self, cloud_prop): assert boto, "boto is not installed, cannot access AWS" - assert LooseVersion(boto.Version) >= BOTO_REQUIREMENT, "boto version is too old, cannot access AWS" + assert boto_is_current, "boto version is too old, cannot access AWS" cloudbase.Provider.__init__(self, AWS_EC2, cloud_prop) self.log = logging.getLogger(AWS_EC2) self.region = cloud_prop["region"] diff --git a/tests/test_cloud_aws_comparison.py b/tests/test_cloud_aws_comparison.py index 3e339de..2f9978b 100644 --- a/tests/test_cloud_aws_comparison.py +++ b/tests/test_cloud_aws_comparison.py @@ -1,7 +1,10 @@ -from poni import cloud +from nose import SkipTest +from poni import cloud, cloud_aws def test_hash(): """validate aws provider hash and comparison implementation""" + if not cloud_aws.boto_is_current: + raise SkipTest("boto is not installed or is too old") sky = cloud.Sky() east_prop = dict(provider="aws-ec2", region="us-east-1") east1 = sky.get_provider(east_prop) diff --git a/tests/test_vc.py b/tests/test_vc.py index 0c6f373..4eb9c7b 100644 --- a/tests/test_vc.py +++ b/tests/test_vc.py @@ -1,8 +1,15 @@ -from poni import tool +from nose import SkipTest +from poni import tool, vc from helper import * import subprocess + class TestVersionControl(Helper): + @classmethod + def setupClass(cls): + if not vc.git: + raise SkipTest("GitPython not installed or too old") + def git(self, repo, cmd): full_cmd = ["git", "--git-dir=%s/.git" % repo, @@ -39,4 +46,3 @@ def test_checkpoint(self): assert not poni.run(["vc", "checkpoint", "checkpoint changes"]) assert self.git(repo, ["status", "-s"]) == "" assert "checkpoint changes" in self.git(repo, ["log"]) -