Skip to content

Commit

Permalink
[cloud][test] Use pytest conditional imports instead of nose/SkipTest (
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansb authored Mar 2, 2017
1 parent 7b2c013 commit fc0ae5e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 38 deletions.
16 changes: 4 additions & 12 deletions test/units/modules/cloud/amazon/test_ec2_vpc_nat_gateway.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
from nose.plugins.skip import SkipTest

try:
import boto3
import botocore
HAS_BOTO3 = True
except ImportError:
HAS_BOTO3 = False

if not HAS_BOTO3:
raise SkipTest("test_ec2_vpc_nat_gateway.py requires the python module 'boto3' and 'botocore'")

import pytest
import unittest

boto3 = pytest.importorskip("boto3")
botocore = pytest.importorskip("botocore")

from collections import namedtuple
from ansible.parsing.dataloader import DataLoader
from ansible.vars import VariableManager
Expand Down
16 changes: 4 additions & 12 deletions test/units/modules/cloud/amazon/test_kinesis_stream.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
from nose.plugins.skip import SkipTest

try:
import boto3
import botocore
HAS_BOTO3 = True
except ImportError:
HAS_BOTO3 = False

if not HAS_BOTO3:
raise SkipTest("test_kinesis_stream.py requires the python module 'boto3' and 'botocore'")

import pytest
import unittest

boto3 = pytest.importorskip("boto3")
botocore = pytest.importorskip("botocore")

import ansible.modules.cloud.amazon.kinesis_stream as kinesis_stream

aws_region = 'us-west-2'
Expand Down
7 changes: 3 additions & 4 deletions test/units/modules/cloud/amazon/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)

from nose.plugins.skip import SkipTest
import pytest
boto3 = pytest.importorskip("boto3")

import json
import copy
from ansible.module_utils._text import to_bytes
from ansible.module_utils import basic
from ansible.compat.tests.mock import MagicMock, Mock, patch
from ansible.module_utils.ec2 import HAS_BOTO3
if not HAS_BOTO3:
raise SkipTest("test_ec2_asg.py requires the `boto3`, and `botocore` modules")

# lambda is a keyword so we have to hack this.
_temp = __import__("ansible.modules.cloud.amazon.lambda")
Expand Down
12 changes: 2 additions & 10 deletions test/units/modules/cloud/amazon/test_s3.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
from nose.plugins.skip import SkipTest

try:
import boto
HAS_BOTO = True
except ImportError:
HAS_BOTO = False

if not HAS_BOTO:
raise SkipTest("test_s3.py requires the python module 'boto'")
import pytest
boto = pytest.importorskip("boto")

import unittest
import ansible.modules.cloud.amazon.s3 as s3
Expand Down

0 comments on commit fc0ae5e

Please sign in to comment.