Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #2219/cfdcc05 backport][stable-9] Cleanup tox configs and unit tests (#2219) #2228

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,33 @@ known_ansible_community_aws = ["ansible_collections.community.aws"]

[tool.flynt]
transform-joins = true

[tool.flake8]
# E123, E125 skipped as they are invalid PEP-8.
show-source = true
ignore = ["E123", "E125", "E203", "E402", "E501", "E741", "F401", "F811", "F841", "W503"]
max-line-length = 160
builtins = "_"

[tool.mypy]
disable_error_code = ["import-untyped"]

[tool.ruff]
line-length = 120

[tool.ruff.lint]
# "F401" - unused-imports - We use these imports to maintain historic Interfaces
# "E402" - import not at top of file - General Ansible style puts the documentation at the top.
unfixable = ["F401"]
ignore = ["F401", "E402"]

[tool.pytest]
xfail_strict = true

[tool.coverage.report]
exclude_lines = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain if tests don't hit defensive assertion code:
"raise NotImplementedError",
]
9 changes: 9 additions & 0 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# -*- coding: utf-8 -*-

# This file is part of Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# While it may seem appropriate to import our custom fixtures here, the pytest_ansible pytest plugin
# isn't as agressive as the ansible_test._util.target.pytest.plugins.ansible_pytest_collections plugin
# when it comes to rewriting the import paths and as such we can't import fixtures via their
# absolute import path or across collections.
11 changes: 11 additions & 0 deletions tests/unit/plugins/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-

# This file is part of Ansible
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

# pylint: disable=unused-import

import pytest

from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_maybe_sleep
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_placeboify
2 changes: 2 additions & 0 deletions tests/unit/plugins/modules/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2017 Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
# Copyright: (c) 2023, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

import pytest
from unittest.mock import patch

import pytest

from ansible_collections.community.aws.plugins.modules.dms_endpoint import compare_params


@pytest.mark.parametrize(
"described_params,created_params,expected_result",
[
Expand Down
10 changes: 0 additions & 10 deletions tests/unit/plugins/modules/test_data_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@

from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3

# Magic... Incorrectly identified by pylint as unused
# isort: off
# pylint: disable=unused-import

from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_maybe_sleep
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_placeboify

# pylint: enable=unused-import
# isort: on

from ansible_collections.community.aws.plugins.modules import data_pipeline

if not HAS_BOTO3:
Expand Down
9 changes: 0 additions & 9 deletions tests/unit/plugins/modules/test_directconnect_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@

from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3

# Magic... Incorrectly identified by pylint as unused
# isort: off
# pylint: disable=unused-import
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_maybe_sleep
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_placeboify

# pylint: enable=unused-import
# isort: on

from ansible_collections.community.aws.plugins.modules import directconnect_connection

if not HAS_BOTO3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_conn
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_aws_connection_info

# Magic... Incorrectly identified by pylint as unused
# isort: off
# pylint: disable=unused-import
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_maybe_sleep
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_placeboify

# pylint: enable=unused-import
# isort: on

from ansible_collections.community.aws.plugins.modules import directconnect_link_aggregation_group as lag_module

if not HAS_BOTO3:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@

from ansible_collections.amazon.aws.plugins.module_utils.botocore import HAS_BOTO3

# Magic... Incorrectly identified by pylint as unused
# isort: off
# pylint: disable=unused-import
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_maybe_sleep
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import fixture_placeboify

# pylint: enable=unused-import
# isort: on

from ansible_collections.community.aws.plugins.modules import directconnect_virtual_interface

if not HAS_BOTO3:
Expand Down
Loading
Loading