Remove nose from unittests (#54055)

* Remove nose from unittests

This PR migrates the last of our unittests from using nose to using
pytest.  We don't need to install nose in our testing environments
anymore
This commit is contained in:
Toshio Kuratomi 2019-03-19 18:36:45 -07:00 committed by GitHub
parent dbb782a594
commit f5f4948480
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 24 deletions

View file

@ -62,18 +62,15 @@ If you make multiple changes to the documentation, or add more than a line to it
To work with documentation on your local machine, you need the following packages installed: To work with documentation on your local machine, you need the following packages installed:
.. code-block:: none - libyaml
- PyYAML
- libyaml - six
- PyYAML - tornado
- nose - pyparsing
- six - gcc
- tornado - jinja2
- pyparsing - rstcheck
- gcc - sphinx
- jinja2
- rstcheck
- sphinx
.. note:: .. note::

View file

@ -4,7 +4,6 @@ cryptography
pycrypto pycrypto
jinja2 jinja2
mock mock
nose
passlib passlib
pytest pytest
pytest-mock pytest-mock

View file

@ -6,10 +6,10 @@
# To execute this by hand: # To execute this by hand:
# 1) cd <checkoutdir> # 1) cd <checkoutdir>
# 2) source hacking/env-setup # 2) source hacking/env-setup
# 3) PYTHONPATH=./lib nosetests -d -w test -v --nocapture sanity/validate-modules # 3) PYTHONPATH=./lib pytest -v sanity/validate-modules
import re import re
from ansible.compat.tests import unittest import unittest
# TYPE_REGEX = re.compile(r'.*\stype\(.*') # TYPE_REGEX = re.compile(r'.*\stype\(.*')
# TYPE_REGEX = re.compile(r'.*(if|or)\stype\(.*') # TYPE_REGEX = re.compile(r'.*(if|or)\stype\(.*')

View file

@ -10,9 +10,12 @@ import os
import json import json
import sys import sys
from nose.plugins.skip import SkipTest import pytest
pytestmark = []
if sys.version_info < (2, 7): if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 2.7") pytestmark.append(pytest.mark.skip("F5 Ansible modules require Python >= 2.7"))
from units.compat import unittest from units.compat import unittest
from units.compat.mock import Mock from units.compat.mock import Mock
@ -60,7 +63,10 @@ except ImportError:
from f5.utils.responses.handlers import Stats from f5.utils.responses.handlers import Stats
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
except ImportError: except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library") pytestmark.append(pytest.mark.skip("F5 Ansible modules require the f5-sdk Python library"))
# pytestmark will cause this test to skip but we have to define A so that classes can be
# defined below
A = object
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {} fixture_data = {}

View file

@ -11,9 +11,10 @@ import json
import pytest import pytest
import sys import sys
from nose.plugins.skip import SkipTest pytestmark = []
if sys.version_info < (2, 7): if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 2.7") pytestmark.append(pytest.mark.skip("F5 Ansible modules require Python >= 2.7"))
from units.compat import unittest from units.compat import unittest
from units.compat.mock import Mock from units.compat.mock import Mock
@ -38,7 +39,8 @@ except ImportError:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
except ImportError: except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library") pytestmark.append(pytest.mark.skip("F5 Ansible modules require the f5-sdk Python library"))
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {} fixture_data = {}

View file

@ -11,9 +11,10 @@ import json
import pytest import pytest
import sys import sys
from nose.plugins.skip import SkipTest pytestmark = []
if sys.version_info < (2, 7): if sys.version_info < (2, 7):
raise SkipTest("F5 Ansible modules require Python >= 2.7") pytestmark.append(pytest.mark.skip("F5 Ansible modules require Python >= 2.7"))
from units.compat import unittest from units.compat import unittest
from units.compat.mock import Mock from units.compat.mock import Mock
@ -38,7 +39,8 @@ except ImportError:
from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError from ansible.module_utils.network.f5.common import iControlUnexpectedHTTPError
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
except ImportError: except ImportError:
raise SkipTest("F5 Ansible modules require the f5-sdk Python library") pytestmark.append(pytest.mark.skip("F5 Ansible modules require the f5-sdk Python library"))
fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures') fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
fixture_data = {} fixture_data = {}