Skip to content

Commit

Permalink
Unit test cleanup. (ansible#60315)
Browse files Browse the repository at this point in the history
* Clean up option parsing unit tests.
* Remove unused unit test marker and import.
  • Loading branch information
mattclay committed Aug 9, 2019
1 parent d61df0a commit 6c09b5c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 37 deletions.
2 changes: 0 additions & 2 deletions test/sanity/ignore.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6916,7 +6916,6 @@ test/lib/ansible_test/_data/requirements/constraints.txt test-constraints
test/lib/ansible_test/_data/requirements/integration.cloud.azure.txt test-constraints
test/lib/ansible_test/_data/setup/windows-httptester.ps1 pslint:PSCustomUseLiteralPath
test/lib/ansible_test/_data/sanity/pylint/plugins/string_format.py use-compat-six
test/units/cli/arguments/test_optparse_helpers.py future-import-boilerplate
test/units/config/manager/test_find_ini_config_file.py future-import-boilerplate
test/units/contrib/inventory/test_vmware_inventory.py future-import-boilerplate
test/units/contrib/inventory/test_vmware_inventory.py metaclass-boilerplate
Expand Down Expand Up @@ -7445,7 +7444,6 @@ test/units/utils/fixtures/collections/ansible_collections/my_namespace/my_collec
test/units/utils/kubevirt_fixtures.py future-import-boilerplate
test/units/utils/kubevirt_fixtures.py metaclass-boilerplate
test/units/utils/test_cleanup_tmp_file.py future-import-boilerplate
test/units/utils/test_context_objects.py future-import-boilerplate
test/units/utils/test_encrypt.py future-import-boilerplate
test/units/utils/test_encrypt.py metaclass-boilerplate
test/units/utils/test_helpers.py future-import-boilerplate
Expand Down
15 changes: 5 additions & 10 deletions test/units/cli/arguments/test_optparse_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# Make coding more python3-ish
from __future__ import (absolute_import, division)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import pytest

from ansible.cli.arguments import option_helpers as opt_help


class TestOptparseHelpersVersion:

def test_version(self):
ver = opt_help.version('ansible-cli-test')
assert 'ansible-cli-test' in ver
assert 'python version' in ver
def test_version():
ver = opt_help.version('ansible-cli-test')
assert 'ansible-cli-test' in ver
assert 'python version' in ver
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import pytest

from oneview_module_loader import OneViewModuleBase
from ansible.modules.remote_management.oneview.oneview_datacenter_facts import DatacenterFactsModule
from hpe_test_utils import FactsParamsTest

Expand All @@ -14,7 +13,6 @@
)


@pytest.mark.resource('datacenters')
class TestDatacenterFactsModule(FactsParamsTest):
@pytest.fixture(autouse=True)
def setUp(self, mock_ansible_module, mock_ov_client):
Expand Down
25 changes: 2 additions & 23 deletions test/units/utils/test_context_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@
# Copyright: (c) 2018, Toshio Kuratomi <tkuratomi@ansible.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# Make coding more python3-ish
from __future__ import (absolute_import, division)
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

try:
import argparse
except ImportError:
argparse = None

import optparse
import argparse

import pytest

Expand Down Expand Up @@ -62,7 +56,6 @@ class FakeOptions:
assert frozenset(co.CLIArgs.from_options(options).items()) == expected


@pytest.mark.skipIf(argparse is None)
def test_cliargs_argparse():
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('integers', metavar='N', type=int, nargs='+',
Expand All @@ -75,17 +68,3 @@ def test_cliargs_argparse():
expected = frozenset((('accumulate', sum), ('integers', (1, 2))))

assert frozenset(co.CLIArgs.from_options(args).items()) == expected


# Can get rid of this test when we port ansible.cli from optparse to argparse
def test_cliargs_optparse():
parser = optparse.OptionParser(description='Process some integers.')
parser.add_option('--sum', dest='accumulate', action='store_const',
const=sum, default=max,
help='sum the integers (default: find the max)')
opts, args = parser.parse_args([u'--sum', u'1', u'2'])
opts.integers = args

expected = frozenset((('accumulate', sum), ('integers', (u'1', u'2'))))

assert frozenset(co.CLIArgs.from_options(opts).items()) == expected

0 comments on commit 6c09b5c

Please sign in to comment.