summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authoromnom62 <75066712+omnom62@users.noreply.github.com>2025-10-19 21:07:22 +1000
committerGitHub <noreply@github.com>2025-10-19 07:07:22 -0400
commit17cbfd4fc4cbf1efb81c18f3f24143f7c0acfa7c (patch)
tree07d4ed14ea38aef0215386fcb41b055c122f53fd /tests
parent79c844c2a58cd84671db78ee063f6b9b5fd942bb (diff)
downloadvyos.vyos-17cbfd4fc4cbf1efb81c18f3f24143f7c0acfa7c.tar.gz
vyos.vyos-17cbfd4fc4cbf1efb81c18f3f24143f7c0acfa7c.zip
Fixes for sanity checks broken by upstream (#435)
* init for upstream sanity checks * PY3 removed * procenv.py PY3 fix * changelog * Bulk commit of linter changes * Clean-up
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/mock/procenv.py19
-rw-r--r--tests/unit/mock/yaml_helper.py45
-rw-r--r--tests/unit/modules/conftest.py3
3 files changed, 16 insertions, 51 deletions
diff --git a/tests/unit/mock/procenv.py b/tests/unit/mock/procenv.py
index d7f3dc95..d21e2a0e 100644
--- a/tests/unit/mock/procenv.py
+++ b/tests/unit/mock/procenv.py
@@ -29,7 +29,6 @@ from contextlib import contextmanager
from io import BytesIO, StringIO
from ansible.module_utils._text import to_bytes
-from ansible.module_utils.six import PY3
from ansible_collections.vyos.vyos.tests.unit.compat import unittest
@@ -42,11 +41,11 @@ 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))
+ # 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
@@ -65,10 +64,10 @@ def swap_stdout():
"""
old_stdout = sys.stdout
- if PY3:
- fake_stream = StringIO()
- else:
- fake_stream = BytesIO()
+ # if PY3:
+ fake_stream = StringIO()
+ # else:
+ # fake_stream = BytesIO()
try:
sys.stdout = fake_stream
diff --git a/tests/unit/mock/yaml_helper.py b/tests/unit/mock/yaml_helper.py
index 2e857592..2cfd7d65 100644
--- a/tests/unit/mock/yaml_helper.py
+++ b/tests/unit/mock/yaml_helper.py
@@ -6,7 +6,6 @@ import io
import yaml
-from ansible.module_utils.six import PY3
from ansible.parsing.yaml.dumper import AnsibleDumper
from ansible.parsing.yaml.loader import AnsibleLoader
@@ -22,17 +21,11 @@ class YamlTestUtils(object):
def _dump_stream(self, obj, stream, dumper=None):
"""Dump to a py2-unicode or py3-string stream."""
- if PY3:
- return yaml.dump(obj, stream, Dumper=dumper)
- else:
- return yaml.dump(obj, stream, Dumper=dumper, encoding=None)
+ return yaml.dump(obj, stream, Dumper=dumper)
def _dump_string(self, obj, dumper=None):
"""Dump to a py2-unicode or py3-string"""
- if PY3:
- return yaml.dump(obj, Dumper=dumper)
- else:
- return yaml.dump(obj, Dumper=dumper, encoding=None)
+ return yaml.dump(obj, Dumper=dumper)
def _dump_load_cycle(self, obj):
# Each pass though a dump or load revs the 'generation'
@@ -89,22 +82,8 @@ class YamlTestUtils(object):
stream_obj_from_stream = io.StringIO()
stream_obj_from_string = io.StringIO()
- if PY3:
- yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
- yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
- else:
- yaml.dump(
- obj_from_stream,
- stream_obj_from_stream,
- Dumper=AnsibleDumper,
- encoding=None,
- )
- yaml.dump(
- obj_from_stream,
- stream_obj_from_string,
- Dumper=AnsibleDumper,
- encoding=None,
- )
+ yaml.dump(obj_from_stream, stream_obj_from_stream, Dumper=AnsibleDumper)
+ yaml.dump(obj_from_stream, stream_obj_from_string, Dumper=AnsibleDumper)
yaml_string_stream_obj_from_stream = stream_obj_from_stream.getvalue()
yaml_string_stream_obj_from_string = stream_obj_from_string.getvalue()
@@ -112,20 +91,8 @@ class YamlTestUtils(object):
stream_obj_from_stream.seek(0)
stream_obj_from_string.seek(0)
- if PY3:
- yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
- yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
- else:
- yaml_string_obj_from_stream = yaml.dump(
- obj_from_stream,
- Dumper=AnsibleDumper,
- encoding=None,
- )
- yaml_string_obj_from_string = yaml.dump(
- obj_from_string,
- Dumper=AnsibleDumper,
- encoding=None,
- )
+ yaml_string_obj_from_stream = yaml.dump(obj_from_stream, Dumper=AnsibleDumper)
+ yaml_string_obj_from_string = yaml.dump(obj_from_string, Dumper=AnsibleDumper)
assert yaml_string == yaml_string_obj_from_stream
assert yaml_string == yaml_string_obj_from_stream == yaml_string_obj_from_string
diff --git a/tests/unit/modules/conftest.py b/tests/unit/modules/conftest.py
index 41465c30..0f36839e 100644
--- a/tests/unit/modules/conftest.py
+++ b/tests/unit/modules/conftest.py
@@ -11,12 +11,11 @@ import pytest
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common._collections_compat import MutableMapping
-from ansible.module_utils.six import string_types
@pytest.fixture
def patch_ansible_module(request, mocker):
- if isinstance(request.param, string_types):
+ if isinstance(request.param, str):
args = request.param
elif isinstance(request.param, MutableMapping):
if "ANSIBLE_MODULE_ARGS" not in request.param: