mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-03-07 10:05:18 +01:00
Fix deprecated imports in tests/unit/mock/procenv.py
Replace deprecated module_utils imports: - ansible.module_utils._text -> ansible.module_utils.common.text.converters - ansible.module_utils.six.PY3 -> removed (Python 2 code paths removed) Fixes #686 Co-authored-by: Cursor AI Signed-off-by: Pavel Bar <pbar@redhat.com>
This commit is contained in:
parent
be431d23b5
commit
0c210428cf
2 changed files with 4 additions and 12 deletions
|
|
@ -1,4 +1,3 @@
|
|||
tests/utils/shippable/timing.py shebang
|
||||
tests/unit/mock/procenv.py pylint:ansible-bad-import-from
|
||||
tests/unit/mock/yaml_helper.py pylint:ansible-bad-import-from
|
||||
tests/unit/modules/conftest.py pylint:ansible-bad-import-from
|
||||
|
|
|
|||
|
|
@ -26,8 +26,7 @@ import json
|
|||
from contextlib import contextmanager
|
||||
from io import BytesIO, StringIO
|
||||
from ansible_collections.ansible.posix.tests.unit.compat import unittest
|
||||
from ansible.module_utils.six import PY3
|
||||
from ansible.module_utils._text import to_bytes
|
||||
from ansible.module_utils.common.text.converters import to_bytes
|
||||
|
||||
|
||||
@contextmanager
|
||||
|
|
@ -38,11 +37,8 @@ def swap_stdin_and_argv(stdin_data='', argv_data=tuple()):
|
|||
real_stdin = sys.stdin
|
||||
real_argv = sys.argv
|
||||
|
||||
if PY3:
|
||||
fake_stream = StringIO(stdin_data)
|
||||
fake_stream.buffer = BytesIO(to_bytes(stdin_data))
|
||||
else:
|
||||
fake_stream = BytesIO(to_bytes(stdin_data))
|
||||
|
||||
try:
|
||||
sys.stdin = fake_stream
|
||||
|
|
@ -61,10 +57,7 @@ def swap_stdout():
|
|||
"""
|
||||
old_stdout = sys.stdout
|
||||
|
||||
if PY3:
|
||||
fake_stream = StringIO()
|
||||
else:
|
||||
fake_stream = BytesIO()
|
||||
|
||||
try:
|
||||
sys.stdout = fake_stream
|
||||
|
|
|
|||
Loading…
Reference in a new issue