Remove tests code/skips targeted for Py<3.6

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2022-12-05 11:17:44 +00:00 committed by Pedro Algarvio
parent 803344e791
commit 8a769342d6
18 changed files with 16 additions and 129 deletions

View file

@ -16,8 +16,6 @@ from tests.support.helpers import VirtualEnv
)
@pytest.mark.requires_network
def test_list_available_packages(modules, pip_version, tmp_path):
if sys.version_info < (3, 6) and pip_version == "pip>=21.0":
pytest.skip("{} is not available on Py3.5".format(pip_version))
if sys.version_info >= (3, 10) and pip_version == "pip==9.0.3":
pytest.skip("{} is not available on Py3.10".format(pip_version))
with VirtualEnv(venv_dir=tmp_path, pip_requirement=pip_version) as virtualenv:

View file

@ -1,5 +1,4 @@
import pathlib
import sys
import attr
import pytest
@ -13,9 +12,6 @@ from salt.ext.tornado import locks
pytestmark = [
# Windows does not support POSIX IPC
pytest.mark.skip_on_windows,
pytest.mark.skipif(
sys.version_info < (3, 6), reason="The IOLoop blocks under Py3.5 on these tests"
),
]

View file

@ -208,26 +208,16 @@ def test_interrupt_on_long_running_job(salt_cli, salt_master, salt_minion):
terminal_stdout.flush()
terminal_stdout.seek(0)
if sys.version_info < (3, 6): # pragma: no cover
stdout = proc._translate_newlines(
terminal_stdout.read(), __salt_system_encoding__
)
else:
stdout = proc._translate_newlines(
terminal_stdout.read(), __salt_system_encoding__, sys.stdout.errors
)
stdout = proc._translate_newlines(
terminal_stdout.read(), __salt_system_encoding__, sys.stdout.errors
)
terminal_stdout.close()
terminal_stderr.flush()
terminal_stderr.seek(0)
if sys.version_info < (3, 6): # pragma: no cover
stderr = proc._translate_newlines(
terminal_stderr.read(), __salt_system_encoding__
)
else:
stderr = proc._translate_newlines(
terminal_stderr.read(), __salt_system_encoding__, sys.stderr.errors
)
stderr = proc._translate_newlines(
terminal_stderr.read(), __salt_system_encoding__, sys.stderr.errors
)
terminal_stderr.close()
ret = ProcessResult(
returncode=proc.returncode, stdout=stdout, stderr=stderr, cmdline=proc.args

View file

@ -213,26 +213,16 @@ def test_setup(salt_ssh_cli, ssh_container_name, ssh_sub_container_name, ssh_pas
terminal_stdout.flush()
terminal_stdout.seek(0)
if sys.version_info < (3, 6): # pragma: no cover
stdout = proc._translate_newlines(
terminal_stdout.read(), __salt_system_encoding__
)
else:
stdout = proc._translate_newlines(
terminal_stdout.read(), __salt_system_encoding__, sys.stdout.errors
)
stdout = proc._translate_newlines(
terminal_stdout.read(), __salt_system_encoding__, sys.stdout.errors
)
terminal_stdout.close()
terminal_stderr.flush()
terminal_stderr.seek(0)
if sys.version_info < (3, 6): # pragma: no cover
stderr = proc._translate_newlines(
terminal_stderr.read(), __salt_system_encoding__
)
else:
stderr = proc._translate_newlines(
terminal_stderr.read(), __salt_system_encoding__, sys.stderr.errors
)
stderr = proc._translate_newlines(
terminal_stderr.read(), __salt_system_encoding__, sys.stderr.errors
)
terminal_stderr.close()
ret = ProcessResult(
returncode=proc.returncode, stdout=stdout, stderr=stderr, cmdline=proc.args

View file

@ -1,4 +1,3 @@
import sys
import textwrap
import pytest
@ -9,12 +8,6 @@ import salt.utils.files
import salt.utils.json
from tests.support.mock import MagicMock, patch
pytestmark = [
pytest.mark.skipif(
sys.version_info < (3, 6), reason="Dictionaries are not ordered under Py3.5"
),
]
@pytest.fixture
def configure_loader_modules(salt_minion_factory):

View file

@ -1,5 +1,4 @@
import logging
import sys
import pytest
@ -31,10 +30,6 @@ def configure_loader_modules():
}
@pytest.mark.skipif(
sys.version_info[0] == 3 and sys.version_info[1] <= 5,
reason="run on Python 3.6 or greater where OrderedDict is default",
)
def test_netdev():
"""
Test status.netdev for AIX

View file

@ -1,8 +1,6 @@
"""
:codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
"""
import sys
import pytest
import salt.modules.disk as disk
@ -228,9 +226,6 @@ def test_wipe():
mock.assert_called_once_with("wipefs -a /dev/sda", python_shell=False)
@pytest.mark.skipif(
sys.version_info < (3, 6), reason="Py3.5 dictionaries are not ordered"
)
def test_tune():
mock = MagicMock(
return_value=(

View file

@ -6,7 +6,6 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"""
import re
import sys
import pytest
@ -19,9 +18,6 @@ def configure_loader_modules():
return {mdadm: {}}
@pytest.mark.skipif(
sys.version_info < (3, 6), reason="Py3.5 dictionaries are not ordered"
)
def test_create():
mock = MagicMock(return_value="salt")
with patch.dict(mdadm.__salt__, {"cmd.run": mock}), patch(
@ -60,9 +56,6 @@ def test_create():
)
@pytest.mark.skipif(
sys.version_info < (3, 6), reason="Py3.5 dictionaries are not ordered"
)
def test_create_metadata():
mock = MagicMock(return_value="salt")
with patch.dict(mdadm.__salt__, {"cmd.run": mock}), patch(

View file

@ -5,7 +5,6 @@
import logging
import os
import shutil
import sys
import textwrap
import pytest
@ -409,10 +408,6 @@ def test_set_filesystems():
)
@pytest.mark.skipif(
sys.version_info[0] == 3 and sys.version_info[1] <= 5,
reason="run on Python 3.6 or greater where OrderedDict is default",
)
@pytest.mark.skip_on_windows(
reason="Not supported on Windows, does not handle tabs well"
)

View file

@ -1,6 +1,5 @@
import copy
import logging
import sys
import pytest
@ -247,7 +246,6 @@ def test_pct_summary_output():
assert " file2" in actual_output
@skipIf(sys.version_info < (3, 6), "RIP Python 3.5")
def test__compress_ids():
"""
Tests for expected data return for _compress_ids

View file

@ -1,5 +1,3 @@
import sys
import pytest
import salt.proxy.restconf as restconf
@ -61,10 +59,6 @@ def test_if_text_is_provided_as_dict_payload_then_provided_string_should_be_used
assert call.kwargs["data"] == expected_data
@pytest.mark.skipif(
sys.version_info[0] == 3 and sys.version_info[1] <= 5,
reason="run on Python 3.6 or greater where OrderedDict is default",
)
def test_if_dict_is_provided_as_dict_payload_then_json_text_should_be_provided(
patch_conn_args, fake_query
):

View file

@ -17,7 +17,6 @@ import salt.utils.platform
from salt.serializers import SerializationError
from salt.serializers.yaml import EncryptedString
from salt.utils.odict import OrderedDict
from tests.support.helpers import ON_PY35
SKIP_MESSAGE = "{} is unavailable, have prerequisites been met?"
@ -109,7 +108,6 @@ def test_compare_sls_vs_yaml():
@pytest.mark.skipif(yaml.available is False, reason=SKIP_MESSAGE.format("yaml"))
@pytest.mark.skipif(yamlex.available is False, reason=SKIP_MESSAGE.format("sls"))
@pytest.mark.skipif(ON_PY35 is True, reason="This test is unreliable under Py3.5")
def test_compare_sls_vs_yaml_with_jinja():
tpl = "{{ data }}"
env = jinja2.Environment()

View file

@ -1,5 +1,3 @@
import sys
import pytest
import salt.utils.data
@ -10,10 +8,6 @@ def test_get_value_simple_path():
assert [{"value": "foo"}] == salt.utils.data.get_value(data, "a:b:c")
@pytest.mark.skipif(
sys.version_info < (3, 6),
reason="Test will randomly fail since Python3.5 does not have ordered dictionaries",
)
def test_get_value_placeholder_dict():
data = {"a": {"b": {"name": "foo"}, "c": {"name": "bar"}}}
assert [
@ -22,10 +16,6 @@ def test_get_value_placeholder_dict():
] == salt.utils.data.get_value(data, "a:{id}:name")
@pytest.mark.skipif(
sys.version_info < (3, 6),
reason="Test will randomly fail since Python3.5 does not have ordered dictionaries",
)
def test_get_value_placeholder_list():
data = {"a": [{"name": "foo"}, {"name": "bar"}]}
assert [
@ -34,10 +24,6 @@ def test_get_value_placeholder_list():
] == salt.utils.data.get_value(data, "a:{id}:name")
@pytest.mark.skipif(
sys.version_info < (3, 6),
reason="Test will randomly fail since Python3.5 does not have ordered dictionaries",
)
def test_get_value_nested_placeholder():
data = {
"a": {

View file

@ -57,8 +57,6 @@ PRE_PYTEST_SKIP_REASON = (
PRE_PYTEST_SKIP = pytest.mark.skip_on_env(
"PRE_PYTEST_DONT_SKIP", present=False, reason=PRE_PYTEST_SKIP_REASON
)
ON_PY35 = sys.version_info < (3, 6)
SKIP_INITIAL_PHOTONOS_FAILURES = pytest.mark.skip_on_env(
"SKIP_INITIAL_PHOTONOS_FAILURES",
eq="1",
@ -1632,22 +1630,6 @@ class PatchedEnviron:
self.original_environ = os.environ.copy()
for key in self.cleanup_keys:
os.environ.pop(key, None)
# Make sure there are no unicode characters in the self.kwargs if we're
# on Python 2. These are being added to `os.environ` and causing
# problems
if sys.version_info < (3,):
kwargs = self.kwargs.copy()
clean_kwargs = {}
for k in self.kwargs:
key = k
if isinstance(key, str):
key = key.encode("utf-8")
if isinstance(self.kwargs[k], str):
kwargs[k] = kwargs[k].encode("utf-8")
clean_kwargs[key] = kwargs[k]
self.kwargs = clean_kwargs
os.environ.update(**self.kwargs)
return self

View file

@ -47,9 +47,6 @@ import salt.utils.stringutils
__mock_version = tuple(
int(part) for part in mock.__version__.split(".") if part.isdigit()
) # pylint: disable=no-member
if sys.version_info < (3, 6) and __mock_version < (2,):
# We need mock >= 2.0.0 before Py3.6
raise ImportError("Please install mock>=2.0.0")
class MockFH:

View file

@ -496,16 +496,10 @@ class SnapperTestCase(TestCase, LoaderModuleMockMixin):
"salt.modules.snapper.snapper.ListConfigs",
MagicMock(return_value=DBUS_RET["ListConfigs"]),
):
if sys.version_info < (2, 7):
self.assertEqual(
snapper.diff(), {"/tmp/foo2": MODULE_RET["DIFF"]["/tmp/foo26"]}
)
else:
self.assertEqual(
snapper.diff(), {"/tmp/foo2": MODULE_RET["DIFF"]["/tmp/foo2"]}
)
self.assertEqual(
snapper.diff(), {"/tmp/foo2": MODULE_RET["DIFF"]["/tmp/foo2"]}
)
@skipIf(sys.version_info < (2, 7), "Python 2.7 required to compare diff properly")
def test_diff_text_files(self):
with patch(
"salt.modules.snapper._get_num_interval", MagicMock(return_value=(55, 0))

View file

@ -1,8 +1,6 @@
import sys
import salt.utils.minions
from tests.support.mock import MagicMock, patch
from tests.support.unit import TestCase, skipIf
from tests.support.unit import TestCase
NODEGROUPS = {
"group1": "L@host1,host2,host3",
@ -346,9 +344,6 @@ class CkMinionsTestCase(TestCase):
self.assertTrue(ret)
@skipIf(
sys.version_info < (2, 7), "Python 2.7 needed for dictionary equality assertions"
)
class TargetParseTestCase(TestCase):
def test_parse_grains_target(self):
"""

View file

@ -346,7 +346,6 @@ class TestMsgpack(TestCase):
for td in test_data:
self._check(td, pack_func, unpack_func)
@skipIf(sys.version_info < (3, 0), "Python 2 passes invalid surrogates")
def _test_ignore_unicode_errors(self, pack_func, unpack_func):
ret = unpack_func(
pack_func(b"abc\xeddef", use_bin_type=False), unicode_errors="ignore", **raw
@ -357,7 +356,6 @@ class TestMsgpack(TestCase):
packed = pack_func(b"abc\xeddef", use_bin_type=False)
self.assertRaises(UnicodeDecodeError, unpack_func, packed, use_list=True, **raw)
@skipIf(sys.version_info < (3, 0), "Python 2 passes invalid surrogates")
def _test_ignore_errors_pack(self, pack_func, unpack_func):
ret = unpack_func(
pack_func("abc\uDC80\uDCFFdef", use_bin_type=True, unicode_errors="ignore"),