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 #1090/1cac4da0 backport][stable-3] import tox.ini #1105

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions tests/unit/module_utils/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import json
import sys
from io import BytesIO
import warnings

import pytest

import ansible.module_utils.basic
import ansible.module_utils.common
from ansible.module_utils.six import PY3, string_types
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common._collections_compat import MutableMapping
Expand All @@ -23,6 +25,13 @@ def stdin(mocker, request):
old_argv = sys.argv
sys.argv = ['ansible_unittest']

for var in ["_global_warnings", "_global_deprecations"]:
if hasattr(ansible.module_utils.common.warnings, var):
setattr(ansible.module_utils.common.warnings, var, [])
else:
# No need to reset the value
warnings.warn("deprecated")

if isinstance(request.param, string_types):
args = request.param
elif isinstance(request.param, MutableMapping):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import botocore
import boto3
import json
import warnings

from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule
from pprint import pprint
Expand Down
20 changes: 20 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[tox]
skipsdist=True
envlist = clean,ansible{2.12,2.13}-py{38,39,310}-{with_constraints,without_constraints}

[testenv]
deps =
pytest
pytest-cov
ansible2.12: ansible-core>2.12,<2.13
ansible2.13: ansible-core>2.13,<2.14
!ansible2.12-!ansible2.13: ansible-core
pytest-ansible-units
-rtest-requirements.txt
with_constraints: -rtests/unit/constraints.txt
commands = pytest --cov-report html --cov plugins {posargs:tests/}

[testenv:clean]
deps = coverage
skip_install = true
commands = coverage erase