Port some tests away from nose as examples (#33437)
We don't need to use both nose and pytest. Once we get rid of all uses of nose we can remove the extra dependency
This commit is contained in:
parent
c35a562345
commit
e499bccbaa
7 changed files with 19 additions and 23 deletions
|
@ -22,8 +22,6 @@ __metaclass__ = type
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from nose.tools import eq_, raises
|
|
||||||
|
|
||||||
from ansible.compat.tests import unittest
|
from ansible.compat.tests import unittest
|
||||||
from ansible.module_utils.json_utils import _filter_non_json_lines
|
from ansible.module_utils.json_utils import _filter_non_json_lines
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,15 @@
|
||||||
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
import pytest
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from ansible.module_utils.ec2 import HAS_BOTO3
|
from ansible.module_utils.ec2 import HAS_BOTO3
|
||||||
from units.modules.utils import set_module_args
|
from units.modules.utils import set_module_args
|
||||||
|
|
||||||
if not HAS_BOTO3:
|
if not HAS_BOTO3:
|
||||||
raise SkipTest("test_api_gateway.py requires the `boto3` and `botocore` modules")
|
pytestmark = pytest.mark.skip("test_api_gateway.py requires the `boto3` and `botocore` modules")
|
||||||
|
|
||||||
import ansible.modules.cloud.amazon.aws_api_gateway as agw
|
import ansible.modules.cloud.amazon.aws_api_gateway as agw
|
||||||
|
|
||||||
|
|
|
@ -15,20 +15,18 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import pytest
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import collections
|
import collections
|
||||||
|
|
||||||
|
import pytest
|
||||||
from . placebo_fixtures import placeboify, maybe_sleep
|
from . placebo_fixtures import placeboify, maybe_sleep
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
|
|
||||||
from ansible.modules.cloud.amazon import data_pipeline
|
from ansible.modules.cloud.amazon import data_pipeline
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text
|
||||||
|
|
||||||
try:
|
# test_api_gateway.py requires the `boto3` and `botocore` modules
|
||||||
import boto3
|
boto3 = pytest.importorskip('boto3')
|
||||||
except ImportError:
|
|
||||||
raise SkipTest("test_api_gateway.py requires the `boto3` and `botocore` modules")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='module')
|
@pytest.fixture(scope='module')
|
||||||
|
|
|
@ -5,16 +5,17 @@
|
||||||
|
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
|
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
import json
|
import json
|
||||||
import pytest
|
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from ansible.module_utils._text import to_bytes
|
from ansible.module_utils._text import to_bytes
|
||||||
from ansible.module_utils import basic
|
from ansible.module_utils import basic
|
||||||
from ansible.module_utils.ec2 import HAS_BOTO3
|
from ansible.module_utils.ec2 import HAS_BOTO3
|
||||||
|
|
||||||
if not HAS_BOTO3:
|
if not HAS_BOTO3:
|
||||||
raise SkipTest("test_elb_application_lb.py requires the `boto3` and `botocore` modules")
|
pytestmark = pytest.mark.skip("test_elb_application_lb.py requires the `boto3` and `botocore` modules")
|
||||||
|
|
||||||
import ansible.modules.cloud.amazon.elb_application_lb as elb_module
|
import ansible.modules.cloud.amazon.elb_application_lb as elb_module
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,14 @@ from __future__ import (absolute_import, division, print_function)
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
|
||||||
from nose.plugins.skip import SkipTest
|
import pytest
|
||||||
|
|
||||||
from ansible.module_utils.aws.core import HAS_BOTO3
|
from ansible.module_utils.aws.core import HAS_BOTO3
|
||||||
from ansible.compat.tests.mock import MagicMock
|
from ansible.compat.tests.mock import MagicMock
|
||||||
from units.modules.utils import set_module_args
|
from units.modules.utils import set_module_args
|
||||||
|
|
||||||
if not HAS_BOTO3:
|
if not HAS_BOTO3:
|
||||||
raise SkipTest("test_api_gateway.py requires the `boto3` and `botocore` modules")
|
pytestmark = pytest.mark.skip("test_api_gateway.py requires the `boto3` and `botocore` modules")
|
||||||
|
|
||||||
# these are here cause ... boto!
|
# these are here cause ... boto!
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
|
|
|
@ -5,8 +5,7 @@ import unittest
|
||||||
try:
|
try:
|
||||||
import ansible.modules.cloud.amazon.s3 as s3
|
import ansible.modules.cloud.amazon.s3 as s3
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from nose.plugins.skip import SkipTest
|
pytestmark = pytest.mark.skip("This test requires the s3 Python libraries")
|
||||||
raise SkipTest("This test requires the s3 Python libraries")
|
|
||||||
|
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,12 @@
|
||||||
from __future__ import (absolute_import, division, print_function)
|
from __future__ import (absolute_import, division, print_function)
|
||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from ansible.compat.tests import unittest
|
from ansible.compat.tests import unittest
|
||||||
from ansible.plugins.filter.ipaddr import (ipaddr, _netmask_query, nthhost, next_nth_usable,
|
from ansible.plugins.filter.ipaddr import (ipaddr, _netmask_query, nthhost, next_nth_usable,
|
||||||
previous_nth_usable, network_in_usable, network_in_network)
|
previous_nth_usable, network_in_usable, network_in_network)
|
||||||
try:
|
netaddr = pytest.importorskip('netaddr')
|
||||||
import netaddr
|
|
||||||
except ImportError:
|
|
||||||
from nose.plugins.skip import SkipTest
|
|
||||||
raise SkipTest("This test requires the `netaddr` python library")
|
|
||||||
|
|
||||||
|
|
||||||
class TestIpFilter(unittest.TestCase):
|
class TestIpFilter(unittest.TestCase):
|
||||||
|
|
Loading…
Reference in a new issue