Blame SOURCES/network-ansible-test.diff

6e715b
From 7ae16e9ff5291f06ba0d7224a0d6c36b780ea0a2 Mon Sep 17 00:00:00 2001
6e715b
From: Rich Megginson <rmeggins@redhat.com>
6e715b
Date: Wed, 3 Mar 2021 11:37:56 -0700
6e715b
Subject: [PATCH] fix most ansible-test issues, suppress the rest
6e715b
6e715b
Automation Hub, and possibly Galaxy in the future, require the
6e715b
collection to be screened with `ansible-test sanity` among other
6e715b
checks.  The role had a number of issues:
6e715b
* Use `AssertionError` instead of `assert`
6e715b
* Use of `logging` module not in accordance with standards, but these
6e715b
  are ok and the errors were suppressed
6e715b
* Several import errors which are ok because they are checked
6e715b
  elsewhere
6e715b
* Many of the module files use `#!` shebang - not sure why, but
6e715b
  the usage is allowed
6e715b
* __init__.py in the module_utils directories must be empty, so a
6e715b
  new file myerror.py was added to move the code from __init__.py
6e715b
* The documentation block in the module was not properly constructed
6e715b
  or formatted.
6e715b
* shellcheck issues, including removing unused files
6e715b
* use `dummy` instead of `_` (underscore) for variables that are
6e715b
  unused
6e715b
6e715b
add WARNING to module docs - collection users should not use directly
6e715b
6e715b
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
6e715b
(cherry picked from commit 7459a29e9104bf01987399153baf0a1c1df05929)
6e715b
---
6e715b
 .github/workflows/tox.yml                     |  4 +-
6e715b
 .sanity-ansible-ignore-2.9.txt                | 47 ++++++++++
6e715b
 README.md                                     |  2 +-
6e715b
 library/network_connections.py                | 88 ++++++++++++-------
6e715b
 module_utils/network_lsr/__init__.py          |  7 --
6e715b
 .../network_lsr/argument_validator.py         |  9 +-
6e715b
 module_utils/network_lsr/ethtool.py           |  6 +-
6e715b
 module_utils/network_lsr/myerror.py           | 11 +++
6e715b
 module_utils/network_lsr/nm/__init__.py       |  4 +
6e715b
 .../network_lsr/nm/active_connection.py       | 35 ++++----
6e715b
 module_utils/network_lsr/nm/client.py         |  4 +
6e715b
 module_utils/network_lsr/nm/connection.py     | 18 ++--
6e715b
 module_utils/network_lsr/nm/error.py          |  4 +
6e715b
 module_utils/network_lsr/nm/provider.py       |  8 +-
6e715b
 module_utils/network_lsr/nm_provider.py       |  4 +
6e715b
 module_utils/network_lsr/utils.py             | 10 ++-
6e715b
 tests/ensure_provider_tests.py                |  8 +-
6e715b
 tests/get_coverage.sh                         |  6 +-
6e715b
 tests/get_total_coverage.sh                   |  2 +-
6e715b
 tests/integration/test_ethernet.py            |  4 +-
6e715b
 tests/merge_coverage.sh                       |  3 +
6e715b
 tests/setup_module_utils.sh                   | 41 ---------
6e715b
 tox.ini                                       |  3 -
6e715b
 23 files changed, 199 insertions(+), 129 deletions(-)
6e715b
 create mode 100644 .sanity-ansible-ignore-2.9.txt
6e715b
 create mode 100644 module_utils/network_lsr/myerror.py
6e715b
 delete mode 100755 tests/setup_module_utils.sh
6e715b
6e715b
diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml
6e715b
index 207bcba..ba0f4c6 100644
6e715b
--- a/.github/workflows/tox.yml
6e715b
+++ b/.github/workflows/tox.yml
6e715b
@@ -3,7 +3,7 @@ name: tox
6e715b
 on:  # yamllint disable-line rule:truthy
6e715b
   - pull_request
6e715b
 env:
6e715b
-  TOX_LSR: "git+https://github.com/linux-system-roles/tox-lsr@2.2.0"
6e715b
+  TOX_LSR: "git+https://github.com/linux-system-roles/tox-lsr@2.3.0"
6e715b
   LSR_ANSIBLES: 'ansible==2.8.* ansible==2.9.*'
6e715b
   LSR_MSCENARIOS: default
6e715b
   # LSR_EXTRA_PACKAGES: "libdbus-1-dev libgirepository1.0-dev python3-dev"
6e715b
@@ -36,7 +36,7 @@ jobs:
6e715b
           toxenvs="py${toxpyver}"
6e715b
           case "$toxpyver" in
6e715b
           27) toxenvs="${toxenvs},coveralls,flake8,pylint" ;;
6e715b
-          36) toxenvs="${toxenvs},coveralls,black,yamllint,ansible-lint,collection" ;;
6e715b
+          36) toxenvs="${toxenvs},coveralls,black,yamllint,ansible-lint,collection,ansible-test" ;;
6e715b
           37) toxenvs="${toxenvs},coveralls" ;;
6e715b
           38) toxenvs="${toxenvs},coveralls" ;;
6e715b
           esac
6e715b
diff --git a/.sanity-ansible-ignore-2.9.txt b/.sanity-ansible-ignore-2.9.txt
6e715b
new file mode 100644
6e715b
index 0000000..439197e
6e715b
--- /dev/null
6e715b
+++ b/.sanity-ansible-ignore-2.9.txt
6e715b
@@ -0,0 +1,47 @@
6e715b
+tests/network/ensure_provider_tests.py compile-2.7!skip
6e715b
+tests/network/ensure_provider_tests.py compile-3.5!skip
6e715b
+plugins/module_utils/network_lsr/nm/__init__.py empty-init!skip
6e715b
+plugins/module_utils/network_lsr/nm/active_connection.py import-2.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/client.py import-2.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/connection.py import-2.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/provider.py import-2.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/active_connection.py import-3.5!skip
6e715b
+plugins/module_utils/network_lsr/nm/client.py import-3.5!skip
6e715b
+plugins/module_utils/network_lsr/nm/connection.py import-3.5!skip
6e715b
+plugins/module_utils/network_lsr/nm/provider.py import-3.5!skip
6e715b
+plugins/module_utils/network_lsr/nm/active_connection.py import-3.6!skip
6e715b
+plugins/module_utils/network_lsr/nm/client.py import-3.6!skip
6e715b
+plugins/module_utils/network_lsr/nm/connection.py import-3.6!skip
6e715b
+plugins/module_utils/network_lsr/nm/provider.py import-3.6!skip
6e715b
+plugins/module_utils/network_lsr/nm/active_connection.py import-3.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/client.py import-3.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/connection.py import-3.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/provider.py import-3.7!skip
6e715b
+plugins/module_utils/network_lsr/nm/active_connection.py import-3.8!skip
6e715b
+plugins/module_utils/network_lsr/nm/client.py import-3.8!skip
6e715b
+plugins/module_utils/network_lsr/nm/connection.py import-3.8!skip
6e715b
+plugins/module_utils/network_lsr/nm/provider.py import-3.8!skip
6e715b
+plugins/module_utils/network_lsr/__init__.py shebang!skip
6e715b
+plugins/module_utils/network_lsr/argument_validator.py shebang!skip
6e715b
+plugins/module_utils/network_lsr/utils.py shebang!skip
6e715b
+plugins/module_utils/network_lsr/myerror.py shebang!skip
6e715b
+tests/network/covstats shebang!skip
6e715b
+tests/network/ensure_provider_tests.py shebang!skip
6e715b
+tests/network/get_coverage.sh shebang!skip
6e715b
+tests/network/get_total_coverage.sh shebang!skip
6e715b
+tests/network/merge_coverage.sh shebang!skip
6e715b
+tests/network/ensure_provider_tests.py future-import-boilerplate!skip
6e715b
+tests/network/integration/conftest.py future-import-boilerplate!skip
6e715b
+tests/network/integration/test_ethernet.py future-import-boilerplate!skip
6e715b
+tests/network/unit/test_network_connections.py future-import-boilerplate!skip
6e715b
+tests/network/unit/test_nm_provider.py future-import-boilerplate!skip
6e715b
+tests/network/ensure_provider_tests.py metaclass-boilerplate!skip
6e715b
+tests/network/integration/conftest.py metaclass-boilerplate!skip
6e715b
+tests/network/integration/test_ethernet.py metaclass-boilerplate!skip
6e715b
+tests/network/unit/test_network_connections.py metaclass-boilerplate!skip
6e715b
+tests/network/unit/test_nm_provider.py metaclass-boilerplate!skip
6e715b
+plugins/modules/network_connections.py validate-modules:missing-examples
6e715b
+plugins/modules/network_connections.py validate-modules:missing-gplv3-license
6e715b
+plugins/modules/network_connections.py validate-modules:no-default-for-required-parameter
6e715b
+plugins/modules/network_connections.py validate-modules:parameter-type-not-in-doc
6e715b
+plugins/modules/network_connections.py validate-modules:undocumented-parameter
6e715b
diff --git a/README.md b/README.md
6e715b
index c1462b6..c257c08 100644
6e715b
--- a/README.md
6e715b
+++ b/README.md
6e715b
@@ -145,7 +145,7 @@ a consequence, `state: up` always changes the system.
6e715b
 
6e715b
 You can deactivate a connection profile, even if is currently not active. As a consequence, `state: down` always changes the system.
6e715b
 
6e715b
-Note that if the `state` option is unset, the connection profile’s runtime state will not be changed.
6e715b
+Note that if the `state` option is unset, the connection profile's runtime state will not be changed.
6e715b
 
6e715b
 
6e715b
 ### `persistent_state`
6e715b
diff --git a/library/network_connections.py b/library/network_connections.py
6e715b
index 3224892..3a6e47f 100644
6e715b
--- a/library/network_connections.py
6e715b
+++ b/library/network_connections.py
6e715b
@@ -2,6 +2,30 @@
6e715b
 # -*- coding: utf-8 -*-
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
+DOCUMENTATION = """
6e715b
+---
6e715b
+module: network_connections
6e715b
+author: Thomas Haller (@thom311)
6e715b
+short_description: module for network role to manage connection profiles
6e715b
+requirements: [pygobject, dbus, NetworkManager]
6e715b
+version_added: "2.0"
6e715b
+description:
6e715b
+  - "WARNING: Do not use this module directly! It is only for role internal use."
6e715b
+  - |
6e715b
+    Manage networking profiles (connections) for NetworkManager and
6e715b
+    initscripts networking providers. Documentation needs to be written. Note
6e715b
+    that the network_connections module tightly integrates with the network
6e715b
+    role and currently it is not expected to use this module outside the role.
6e715b
+    Thus, consult README.md for examples for the role.  The requirements are
6e715b
+    only for the NetworkManager (nm) provider.
6e715b
+options: {}
6e715b
+"""
6e715b
+
6e715b
+
6e715b
 import errno
6e715b
 import functools
6e715b
 import os
6e715b
@@ -16,7 +40,7 @@ import logging
6e715b
 # pylint: disable=import-error, no-name-in-module
6e715b
 from ansible.module_utils.basic import AnsibleModule
6e715b
 from ansible.module_utils.network_lsr import ethtool  # noqa:E501
6e715b
-from ansible.module_utils.network_lsr import MyError  # noqa:E501
6e715b
+from ansible.module_utils.network_lsr.myerror import MyError  # noqa:E501
6e715b
 
6e715b
 from ansible.module_utils.network_lsr.argument_validator import (  # noqa:E501
6e715b
     ArgUtil,
6e715b
@@ -30,22 +54,6 @@ from ansible.module_utils.network_lsr import nm_provider  # noqa:E501
6e715b
 # pylint: enable=import-error, no-name-in-module
6e715b
 
6e715b
 
6e715b
-DOCUMENTATION = """
6e715b
----
6e715b
-module: network_connections
6e715b
-author: "Thomas Haller (thaller@redhat.com)"
6e715b
-short_description: module for network role to manage connection profiles
6e715b
-requirements: for 'nm' provider requires pygobject, dbus and NetworkManager.
6e715b
-version_added: "2.0"
6e715b
-description: Manage networking profiles (connections) for NetworkManager and
6e715b
-  initscripts networking providers.
6e715b
-options: Documentation needs to be written. Note that the network_connections
6e715b
-  module tightly integrates with the network role and currently it is not
6e715b
-  expected to use this module outside the role. Thus, consult README.md for
6e715b
-  examples for the role.
6e715b
-"""
6e715b
-
6e715b
-
6e715b
 ###############################################################################
6e715b
 PERSISTENT_STATE = "persistent_state"
6e715b
 ABSENT_STATE = "absent"
6e715b
@@ -772,7 +780,7 @@ class NMUtil:
6e715b
         if compare_flags is None:
6e715b
             compare_flags = NM.SettingCompareFlags.IGNORE_TIMESTAMP
6e715b
 
6e715b
-        return not (not (con_a.compare(con_b, compare_flags)))
6e715b
+        return con_a.compare(con_b, compare_flags)
6e715b
 
6e715b
     def connection_is_active(self, con):
6e715b
         NM = Util.NM()
6e715b
@@ -1390,7 +1398,7 @@ class RunEnvironment(object):
6e715b
     def check_mode_set(self, check_mode, connections=None):
6e715b
         c = self._check_mode
6e715b
         self._check_mode = check_mode
6e715b
-        assert (
6e715b
+        if not (
6e715b
             (c is None and check_mode in [CheckMode.PREPARE])
6e715b
             or (
6e715b
                 c == CheckMode.PREPARE
6e715b
@@ -1399,7 +1407,8 @@ class RunEnvironment(object):
6e715b
             or (c == CheckMode.PRE_RUN and check_mode in [CheckMode.REAL_RUN])
6e715b
             or (c == CheckMode.REAL_RUN and check_mode in [CheckMode.DONE])
6e715b
             or (c == CheckMode.DRY_RUN and check_mode in [CheckMode.DONE])
6e715b
-        )
6e715b
+        ):
6e715b
+            raise AssertionError("check_mode value is incorrect {0}".format(c))
6e715b
         self._check_mode_changed(c, check_mode, connections)
6e715b
 
6e715b
 
6e715b
@@ -1461,7 +1470,8 @@ class RunEnvironmentAnsible(RunEnvironment):
6e715b
         warn_traceback=False,
6e715b
         force_fail=False,
6e715b
     ):
6e715b
-        assert idx >= -1
6e715b
+        if not idx >= -1:
6e715b
+            raise AssertionError("idx {0} is less than -1".format(idx))
6e715b
         self._log_idx += 1
6e715b
         self.run_results[idx]["log"].append((severity, msg, self._log_idx))
6e715b
         if severity == LogLevel.ERROR:
6e715b
@@ -1598,14 +1608,15 @@ class Cmd(object):
6e715b
     def connections_data(self):
6e715b
         c = self._connections_data
6e715b
         if c is None:
6e715b
-            assert self.check_mode in [
6e715b
+            if self.check_mode not in [
6e715b
                 CheckMode.DRY_RUN,
6e715b
                 CheckMode.PRE_RUN,
6e715b
                 CheckMode.REAL_RUN,
6e715b
-            ]
6e715b
-            c = []
6e715b
-            for _ in range(0, len(self.connections)):
6e715b
-                c.append({"changed": False})
6e715b
+            ]:
6e715b
+                raise AssertionError(
6e715b
+                    "invalid value {0} for self.check_mode".format(self.check_mode)
6e715b
+                )
6e715b
+            c = [{"changed": False}] * len(self.connections)
6e715b
             self._connections_data = c
6e715b
         return c
6e715b
 
6e715b
@@ -1614,11 +1625,14 @@ class Cmd(object):
6e715b
             c["changed"] = False
6e715b
 
6e715b
     def connections_data_set_changed(self, idx, changed=True):
6e715b
-        assert self._check_mode in [
6e715b
+        if self._check_mode not in [
6e715b
             CheckMode.PRE_RUN,
6e715b
             CheckMode.DRY_RUN,
6e715b
             CheckMode.REAL_RUN,
6e715b
-        ]
6e715b
+        ]:
6e715b
+            raise AssertionError(
6e715b
+                "invalid value {0} for self._check_mode".format(self._check_mode)
6e715b
+            )
6e715b
         if not changed:
6e715b
             return
6e715b
         self.connections_data[idx]["changed"] = changed
6e715b
@@ -1688,7 +1702,10 @@ class Cmd(object):
6e715b
         # modify the connection.
6e715b
 
6e715b
         con = self.connections[idx]
6e715b
-        assert con["state"] in ["up", "down"]
6e715b
+        if con["state"] not in ["up", "down"]:
6e715b
+            raise AssertionError(
6e715b
+                "connection state {0} not 'up' or 'down'".format(con["state"])
6e715b
+            )
6e715b
 
6e715b
         # also check, if the current profile is 'up' with a 'type' (which
6e715b
         # possibly modifies the connection as well)
6e715b
@@ -1736,7 +1753,9 @@ class Cmd(object):
6e715b
         elif self._check_mode != CheckMode.DONE:
6e715b
             c = CheckMode.DONE
6e715b
         else:
6e715b
-            assert False
6e715b
+            raise AssertionError(
6e715b
+                "invalid value {0} for self._check_mode".format(self._check_mode)
6e715b
+            )
6e715b
         self._check_mode = c
6e715b
         self.run_env.check_mode_set(c)
6e715b
         return c
6e715b
@@ -1902,7 +1921,12 @@ class Cmd_nm(Cmd):
6e715b
 
6e715b
             name = connection["name"]
6e715b
             if not name:
6e715b
-                assert connection["persistent_state"] == "absent"
6e715b
+                if not connection["persistent_state"] == "absent":
6e715b
+                    raise AssertionError(
6e715b
+                        "persistent_state must be 'absent' not {0} when there is no connection 'name'".format(
6e715b
+                            connection["persistent_state"]
6e715b
+                        )
6e715b
+                    )
6e715b
                 continue
6e715b
             if name in names:
6e715b
                 exists = names[name]["nm.exists"]
6e715b
@@ -1979,7 +2003,7 @@ class Cmd_nm(Cmd):
6e715b
                     idx, "ethtool.%s specified but not supported by NM", specified
6e715b
                 )
6e715b
 
6e715b
-            for option, _ in specified.items():
6e715b
+            for option in specified.keys():
6e715b
                 nm_name = nm_get_name_fcnt(option)
6e715b
                 if not nm_name:
6e715b
                     self.log_fatal(
6e715b
diff --git a/module_utils/network_lsr/__init__.py b/module_utils/network_lsr/__init__.py
6e715b
index 22c717c..e69de29 100644
6e715b
--- a/module_utils/network_lsr/__init__.py
6e715b
+++ b/module_utils/network_lsr/__init__.py
6e715b
@@ -1,7 +0,0 @@
6e715b
-#!/usr/bin/python3 -tt
6e715b
-# vim: fileencoding=utf8
6e715b
-# SPDX-License-Identifier: BSD-3-Clause
6e715b
-
6e715b
-
6e715b
-class MyError(Exception):
6e715b
-    pass
6e715b
diff --git a/module_utils/network_lsr/argument_validator.py b/module_utils/network_lsr/argument_validator.py
6e715b
index 24ffdc4..f338489 100644
6e715b
--- a/module_utils/network_lsr/argument_validator.py
6e715b
+++ b/module_utils/network_lsr/argument_validator.py
6e715b
@@ -2,12 +2,16 @@
6e715b
 # vim: fileencoding=utf8
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 import posixpath
6e715b
 import socket
6e715b
 import re
6e715b
 
6e715b
 # pylint: disable=import-error, no-name-in-module
6e715b
-from ansible.module_utils.network_lsr import MyError  # noqa:E501
6e715b
+from ansible.module_utils.network_lsr.myerror import MyError  # noqa:E501
6e715b
 from ansible.module_utils.network_lsr.utils import Util  # noqa:E501
6e715b
 
6e715b
 UINT32_MAX = 0xFFFFFFFF
6e715b
@@ -72,7 +76,8 @@ class ArgUtil:
6e715b
 
6e715b
 class ValidationError(MyError):
6e715b
     def __init__(self, name, message):
6e715b
-        Exception.__init__(self, name + ": " + message)
6e715b
+        # pylint: disable=non-parent-init-called
6e715b
+        super(ValidationError, self).__init__(name + ": " + message)
6e715b
         self.error_message = message
6e715b
         self.name = name
6e715b
 
6e715b
diff --git a/module_utils/network_lsr/ethtool.py b/module_utils/network_lsr/ethtool.py
6e715b
index 21e2152..3246bef 100644
6e715b
--- a/module_utils/network_lsr/ethtool.py
6e715b
+++ b/module_utils/network_lsr/ethtool.py
6e715b
@@ -1,5 +1,9 @@
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 import array
6e715b
 import struct
6e715b
 import fcntl
6e715b
@@ -46,7 +50,7 @@ def get_perm_addr(ifname):
6e715b
             res = ecmd.tobytes()
6e715b
         except AttributeError:  # tobytes() is not available in python2
6e715b
             res = ecmd.tostring()
6e715b
-        _, size, perm_addr = struct.unpack("II%is" % MAX_ADDR_LEN, res)
6e715b
+        dummy, size, perm_addr = struct.unpack("II%is" % MAX_ADDR_LEN, res)
6e715b
         perm_addr = Util.mac_ntoa(perm_addr[:size])
6e715b
     except IOError:
6e715b
         perm_addr = None
6e715b
diff --git a/module_utils/network_lsr/myerror.py b/module_utils/network_lsr/myerror.py
6e715b
new file mode 100644
6e715b
index 0000000..f785265
6e715b
--- /dev/null
6e715b
+++ b/module_utils/network_lsr/myerror.py
6e715b
@@ -0,0 +1,11 @@
6e715b
+#!/usr/bin/python3 -tt
6e715b
+# vim: fileencoding=utf8
6e715b
+# SPDX-License-Identifier: BSD-3-Clause
6e715b
+
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
+
6e715b
+class MyError(Exception):
6e715b
+    pass
6e715b
diff --git a/module_utils/network_lsr/nm/__init__.py b/module_utils/network_lsr/nm/__init__.py
6e715b
index 58fbb5a..74c17cb 100644
6e715b
--- a/module_utils/network_lsr/nm/__init__.py
6e715b
+++ b/module_utils/network_lsr/nm/__init__.py
6e715b
@@ -1,5 +1,9 @@
6e715b
 # Relative import is not support by ansible 2.8 yet
6e715b
 # pylint: disable=import-error, no-name-in-module
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 from ansible.module_utils.network_lsr.nm import provider  # noqa:E501
6e715b
 
6e715b
 # pylint: enable=import-error, no-name-in-module
6e715b
diff --git a/module_utils/network_lsr/nm/active_connection.py b/module_utils/network_lsr/nm/active_connection.py
6e715b
index a6c5a37..432142c 100644
6e715b
--- a/module_utils/network_lsr/nm/active_connection.py
6e715b
+++ b/module_utils/network_lsr/nm/active_connection.py
6e715b
@@ -2,6 +2,10 @@
6e715b
 
6e715b
 # Handle NM.ActiveConnection
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 import logging
6e715b
 
6e715b
 # Relative import is not support by ansible 2.8 yet
6e715b
@@ -21,19 +25,15 @@ def deactivate_active_connection(nm_ac, timeout, check_mode):
6e715b
         return False
6e715b
     if not check_mode:
6e715b
         main_loop = client.get_mainloop(timeout)
6e715b
-        logging.debug(
6e715b
-            "Deactivating {id} with timeout {timeout}".format(
6e715b
-                id=nm_ac.get_id(), timeout=timeout
6e715b
-            )
6e715b
-        )
6e715b
+        logging.debug("Deactivating %s with timeout %s", nm_ac.get_id(), timeout)
6e715b
         user_data = main_loop
6e715b
         handler_id = nm_ac.connect(
6e715b
             NM_AC_STATE_CHANGED_SIGNAL, _nm_ac_state_change_callback, user_data
6e715b
         )
6e715b
         logging.debug(
6e715b
-            "Registered {signal} on client.NM.ActiveConnection {id}".format(
6e715b
-                signal=NM_AC_STATE_CHANGED_SIGNAL, id=nm_ac.get_id()
6e715b
-            )
6e715b
+            "Registered %s on client.NM.ActiveConnection %s",
6e715b
+            NM_AC_STATE_CHANGED_SIGNAL,
6e715b
+            nm_ac.get_id(),
6e715b
         )
6e715b
         if nm_ac.props.state != client.NM.ActiveConnectionState.DEACTIVATING:
6e715b
             nm_client = client.get_client()
6e715b
@@ -44,9 +44,7 @@ def deactivate_active_connection(nm_ac, timeout, check_mode):
6e715b
                 _nm_ac_deactivate_call_back,
6e715b
                 user_data,
6e715b
             )
6e715b
-            logging.debug(
6e715b
-                "Deactivating client.NM.ActiveConnection {0}".format(nm_ac.get_id())
6e715b
-            )
6e715b
+            logging.debug("Deactivating client.NM.ActiveConnection %s", nm_ac.get_id())
6e715b
         main_loop.run()
6e715b
     return True
6e715b
 
6e715b
@@ -56,14 +54,13 @@ def _nm_ac_state_change_callback(nm_ac, state, reason, user_data):
6e715b
     if main_loop.is_cancelled:
6e715b
         return
6e715b
     logging.debug(
6e715b
-        "Got client.NM.ActiveConnection state change: {id}: {state} {reason}".format(
6e715b
-            id=nm_ac.get_id(), state=state, reason=reason
6e715b
-        )
6e715b
+        "Got client.NM.ActiveConnection state change: %s: %s %s",
6e715b
+        nm_ac.get_id(),
6e715b
+        state,
6e715b
+        reason,
6e715b
     )
6e715b
     if nm_ac.props.state == client.NM.ActiveConnectionState.DEACTIVATED:
6e715b
-        logging.debug(
6e715b
-            "client.NM.ActiveConnection {0} is deactivated".format(nm_ac.get_id())
6e715b
-        )
6e715b
+        logging.debug("client.NM.ActiveConnection %s is deactivated", nm_ac.get_id())
6e715b
         main_loop.quit()
6e715b
 
6e715b
 
6e715b
@@ -82,9 +79,7 @@ def _nm_ac_deactivate_call_back(nm_client, result, user_data):
6e715b
             client.NM.ManagerError.quark(), client.NM.ManagerError.CONNECTIONNOTACTIVE
6e715b
         ):
6e715b
             logging.info(
6e715b
-                "Connection is not active on {0}, no need to deactivate".format(
6e715b
-                    nm_ac_id
6e715b
-                )
6e715b
+                "Connection is not active on %s, no need to deactivate", nm_ac_id
6e715b
             )
6e715b
             if nm_ac:
6e715b
                 nm_ac.handler_disconnect(handler_id)
6e715b
diff --git a/module_utils/network_lsr/nm/client.py b/module_utils/network_lsr/nm/client.py
6e715b
index 4992887..f47cc53 100644
6e715b
--- a/module_utils/network_lsr/nm/client.py
6e715b
+++ b/module_utils/network_lsr/nm/client.py
6e715b
@@ -1,5 +1,9 @@
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 import logging
6e715b
 
6e715b
 # Relative import is not support by ansible 2.8 yet
6e715b
diff --git a/module_utils/network_lsr/nm/connection.py b/module_utils/network_lsr/nm/connection.py
6e715b
index 6982034..474da8d 100644
6e715b
--- a/module_utils/network_lsr/nm/connection.py
6e715b
+++ b/module_utils/network_lsr/nm/connection.py
6e715b
@@ -2,6 +2,10 @@
6e715b
 
6e715b
 # Handle NM.RemoteConnection
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 import logging
6e715b
 
6e715b
 # Relative import is not support by ansible 2.8 yet
6e715b
@@ -26,9 +30,10 @@ def delete_remote_connection(nm_profile, timeout, check_mode):
6e715b
             user_data,
6e715b
         )
6e715b
         logging.debug(
6e715b
-            "Deleting profile {id}/{uuid} with timeout {timeout}".format(
6e715b
-                id=nm_profile.get_id(), uuid=nm_profile.get_uuid(), timeout=timeout
6e715b
-            )
6e715b
+            "Deleting profile %s/%s with timeout %s",
6e715b
+            nm_profile.get_id(),
6e715b
+            nm_profile.get_uuid(),
6e715b
+            timeout,
6e715b
         )
6e715b
         main_loop.run()
6e715b
     return True
6e715b
@@ -78,9 +83,10 @@ def volatilize_remote_connection(nm_profile, timeout, check_mode):
6e715b
             user_data,
6e715b
         )
6e715b
         logging.debug(
6e715b
-            "Volatilizing profile {id}/{uuid} with timeout {timeout}".format(
6e715b
-                id=nm_profile.get_id(), uuid=nm_profile.get_uuid(), timeout=timeout
6e715b
-            )
6e715b
+            "Volatilizing profile %s/%s with timeout %s",
6e715b
+            nm_profile.get_id(),
6e715b
+            nm_profile.get_uuid(),
6e715b
+            timeout,
6e715b
         )
6e715b
         main_loop.run()
6e715b
     return True
6e715b
diff --git a/module_utils/network_lsr/nm/error.py b/module_utils/network_lsr/nm/error.py
6e715b
index 42014ec..d87bc72 100644
6e715b
--- a/module_utils/network_lsr/nm/error.py
6e715b
+++ b/module_utils/network_lsr/nm/error.py
6e715b
@@ -1,5 +1,9 @@
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 
6e715b
 class LsrNetworkNmError(Exception):
6e715b
     pass
6e715b
diff --git a/module_utils/network_lsr/nm/provider.py b/module_utils/network_lsr/nm/provider.py
6e715b
index 52e7502..567c9d1 100644
6e715b
--- a/module_utils/network_lsr/nm/provider.py
6e715b
+++ b/module_utils/network_lsr/nm/provider.py
6e715b
@@ -1,5 +1,9 @@
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 import logging
6e715b
 
6e715b
 # Relative import is not support by ansible 2.8 yet
6e715b
@@ -25,7 +29,7 @@ class NetworkManagerProvider:
6e715b
                     nm_ac, timeout, check_mode
6e715b
                 )
6e715b
         if not changed:
6e715b
-            logging.info("No active connection for {0}".format(connection_name))
6e715b
+            logging.info("No active connection for %s", connection_name)
6e715b
 
6e715b
         return changed
6e715b
 
6e715b
@@ -49,7 +53,7 @@ class NetworkManagerProvider:
6e715b
                         nm_profile, timeout, check_mode
6e715b
                     )
6e715b
         if not changed:
6e715b
-            logging.info("No connection with UUID {0} to volatilize".format(uuid))
6e715b
+            logging.info("No connection with UUID %s to volatilize", uuid)
6e715b
 
6e715b
         return changed
6e715b
 
6e715b
diff --git a/module_utils/network_lsr/nm_provider.py b/module_utils/network_lsr/nm_provider.py
6e715b
index c75242a..d6168eb 100644
6e715b
--- a/module_utils/network_lsr/nm_provider.py
6e715b
+++ b/module_utils/network_lsr/nm_provider.py
6e715b
@@ -1,6 +1,10 @@
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 """ Support for NetworkManager aka the NM provider """
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 # pylint: disable=import-error, no-name-in-module
6e715b
 from ansible.module_utils.network_lsr.utils import Util  # noqa:E501
6e715b
 
6e715b
diff --git a/module_utils/network_lsr/utils.py b/module_utils/network_lsr/utils.py
6e715b
index 73d9528..bc258fe 100644
6e715b
--- a/module_utils/network_lsr/utils.py
6e715b
+++ b/module_utils/network_lsr/utils.py
6e715b
@@ -2,18 +2,23 @@
6e715b
 # SPDX-License-Identifier: BSD-3-Clause
6e715b
 # vim: fileencoding=utf8
6e715b
 
6e715b
+from __future__ import absolute_import, division, print_function
6e715b
+
6e715b
+__metaclass__ = type
6e715b
+
6e715b
 import socket
6e715b
 import sys
6e715b
 import uuid
6e715b
 
6e715b
 # pylint: disable=import-error, no-name-in-module
6e715b
-from ansible.module_utils.network_lsr import MyError  # noqa:E501
6e715b
+from ansible.module_utils.network_lsr.myerror import MyError  # noqa:E501
6e715b
 
6e715b
 
6e715b
 class Util:
6e715b
 
6e715b
     PY3 = sys.version_info[0] == 3
6e715b
 
6e715b
+    # pylint: disable=undefined-variable
6e715b
     STRING_TYPE = str if PY3 else basestring  # noqa:F821
6e715b
 
6e715b
     @staticmethod
6e715b
@@ -241,7 +246,8 @@ class Util:
6e715b
                     n = int(c, 16) * 16
6e715b
                     i = 1
6e715b
                 else:
6e715b
-                    assert i == 1
6e715b
+                    if not i == 1:
6e715b
+                        raise AssertionError("i != 1 - value is {0}".format(i))
6e715b
                     n = n + int(c, 16)
6e715b
                     i = 2
6e715b
                     b.append(n)
6e715b
diff --git a/tests/ensure_provider_tests.py b/tests/ensure_provider_tests.py
6e715b
index 3620729..4e45e6a 100755
6e715b
--- a/tests/ensure_provider_tests.py
6e715b
+++ b/tests/ensure_provider_tests.py
6e715b
@@ -73,8 +73,6 @@ NM_ONLY_TESTS = {
6e715b
         MINIMUM_VERSION: "'1.25.1'",
6e715b
         "comment": "# NetworkManager 1.25.1 introduced ethtool coalesce support",
6e715b
     },
6e715b
-    "playbooks/tests_802_1x_updated.yml": {},
6e715b
-    "playbooks/tests_802_1x.yml": {},
6e715b
     "playbooks/tests_reapply.yml": {},
6e715b
     # team interface is not supported on Fedora
6e715b
     "playbooks/tests_team.yml": {
6e715b
@@ -117,9 +115,7 @@ def create_nm_playbook(test_playbook):
6e715b
         EXTRA_RUN_CONDITION, ""
6e715b
     )
6e715b
     if extra_run_condition:
6e715b
-        extra_run_condition = "{}{}\n".format(
6e715b
-            EXTRA_RUN_CONDITION_PREFIX, extra_run_condition
6e715b
-        )
6e715b
+        extra_run_condition = f"{EXTRA_RUN_CONDITION_PREFIX}{extra_run_condition}\n"
6e715b
 
6e715b
     nm_version_check = ""
6e715b
     if minimum_nm_version:
6e715b
@@ -212,7 +208,7 @@ def main():
6e715b
 
6e715b
     if missing:
6e715b
         print("ERROR: No NM or initscripts tests found for:\n" + ", \n".join(missing))
6e715b
-        print("Try to generate them with '{} generate'".format(sys.argv[0]))
6e715b
+        print(f"Try to generate them with '{sys.argv[0]} generate'")
6e715b
         returncode = 1
6e715b
 
6e715b
     return returncode
6e715b
diff --git a/tests/get_coverage.sh b/tests/get_coverage.sh
6e715b
index 858a8cf..4524fab 100755
6e715b
--- a/tests/get_coverage.sh
6e715b
+++ b/tests/get_coverage.sh
6e715b
@@ -19,7 +19,6 @@ shift
6e715b
 playbook="${1}"
6e715b
 
6e715b
 coverage_data="remote-coveragedata-${host}-${playbook%.yml}"
6e715b
-coverage="/root/.local/bin/coverage"
6e715b
 
6e715b
 echo "Getting coverage for ${playbook} on ${host}" >&2
6e715b
 
6e715b
@@ -32,10 +31,15 @@ call_ansible() {
6e715b
 }
6e715b
 
6e715b
 remote_coverage_dir="$(mktemp -d /tmp/remote_coverage-XXXXXX)"
6e715b
+# we want to expand ${remote_coverage_dir} here, so tell SC to be quiet
6e715b
+# https://github.com/koalaman/shellcheck/wiki/SC2064
6e715b
+# shellcheck disable=SC2064
6e715b
 trap "rm -rf '${remote_coverage_dir}'" EXIT
6e715b
 ansible-playbook -i "${host}", get_coverage.yml -e "test_playbook=${playbook} destdir=${remote_coverage_dir}"
6e715b
 
6e715b
 #COVERAGE_FILE=remote-coverage coverage combine remote-coverage/tests_*/*/root/.coverage
6e715b
+# https://github.com/koalaman/shellcheck/wiki/SC2046
6e715b
+# shellcheck disable=SC2046
6e715b
 ./merge_coverage.sh coverage "${coverage_data}"-tmp $(find "${remote_coverage_dir}" -type f | tr , _)
6e715b
 
6e715b
 cat > tmp_merge_coveragerc <
6e715b
diff --git a/tests/get_total_coverage.sh b/tests/get_total_coverage.sh
6e715b
index ca61746..6413b18 100755
6e715b
--- a/tests/get_total_coverage.sh
6e715b
+++ b/tests/get_total_coverage.sh
6e715b
@@ -12,7 +12,7 @@ then
6e715b
     exit 1
6e715b
 fi
6e715b
 
6e715b
-rm -f remote-coveragedata* "${coveragedata}"
6e715b
+rm -f remote-coveragedata* "${coverage_data}"
6e715b
 
6e715b
 
6e715b
 # collect pytest coverage
6e715b
diff --git a/tests/integration/test_ethernet.py b/tests/integration/test_ethernet.py
6e715b
index d104d23..4fc7417 100644
6e715b
--- a/tests/integration/test_ethernet.py
6e715b
+++ b/tests/integration/test_ethernet.py
6e715b
@@ -25,10 +25,10 @@ with mock.patch.dict(
6e715b
 class PytestRunEnvironment(nc.RunEnvironment):
6e715b
     def log(self, connections, idx, severity, msg, **kwargs):
6e715b
         if severity == nc.LogLevel.ERROR:
6e715b
-            logging.error("Error: {}".format(connections[idx]))
6e715b
+            logging.error("Error: %s", connections[idx])
6e715b
             raise RuntimeError(msg)
6e715b
         else:
6e715b
-            logging.debug("Log: {}".format(connections[idx]))
6e715b
+            logging.debug("Log: %s", connections[idx])
6e715b
 
6e715b
     def run_command(self, argv, encoding=None):
6e715b
         command = subprocess.Popen(
6e715b
diff --git a/tests/merge_coverage.sh b/tests/merge_coverage.sh
6e715b
index a33e94d..61fcd00 100755
6e715b
--- a/tests/merge_coverage.sh
6e715b
+++ b/tests/merge_coverage.sh
6e715b
@@ -23,6 +23,9 @@ export COVERAGE_FILE="${1}"
6e715b
 shift
6e715b
 
6e715b
 tempdir="$(mktemp -d /tmp/coverage_merge-XXXXXX)"
6e715b
+# we want to expand ${tempdir} here, so tell SC to be quiet
6e715b
+# https://github.com/koalaman/shellcheck/wiki/SC2064
6e715b
+# shellcheck disable=SC2064
6e715b
 trap "rm -rf '${tempdir}'" EXIT
6e715b
 
6e715b
 cp --backup=numbered -- "${@}" "${tempdir}"
6e715b
diff --git a/tests/setup_module_utils.sh b/tests/setup_module_utils.sh
6e715b
deleted file mode 100755
6e715b
index 18d6a00..0000000
6e715b
--- a/tests/setup_module_utils.sh
6e715b
+++ /dev/null
6e715b
@@ -1,41 +0,0 @@
6e715b
-#!/bin/bash
6e715b
-# SPDX-License-Identifier: MIT
6e715b
-
6e715b
-set -euo pipefail
6e715b
-
6e715b
-if [ -n "${DEBUG:-}" ] ; then
6e715b
-    set -x
6e715b
-fi
6e715b
-
6e715b
-if [ ! -d "${1:-}" ] ; then
6e715b
-    echo Either ansible is not installed, or there is no ansible/module_utils
6e715b
-    echo in $1 - Skipping
6e715b
-    exit 0
6e715b
-fi
6e715b
-
6e715b
-if [ ! -d "${2:-}" ] ; then
6e715b
-    echo Role has no module_utils - Skipping
6e715b
-    exit 0
6e715b
-fi
6e715b
-
6e715b
-# we need absolute path for $2
6e715b
-absmoddir=$( readlink -f "$2" )
6e715b
-
6e715b
-# clean up old links to module_utils
6e715b
-for item in "$1"/* ; do
6e715b
-    if lnitem=$( readlink "$item" ) && test -n "$lnitem" ; then
6e715b
-        case "$lnitem" in
6e715b
-            *"${2}"*) rm -f "$item" ;;
6e715b
-        esac
6e715b
-    fi
6e715b
-done
6e715b
-
6e715b
-# add new links to module_utils
6e715b
-for item in "$absmoddir"/* ; do
6e715b
-    case "$item" in
6e715b
-        *__pycache__) continue;;
6e715b
-        *.pyc) continue;;
6e715b
-    esac
6e715b
-    bnitem=$( basename "$item" )
6e715b
-    ln -s "$item" "$1/$bnitem"
6e715b
-done
6e715b
diff --git a/tox.ini b/tox.ini
6e715b
index 6ff26e7..59c58a2 100644
6e715b
--- a/tox.ini
6e715b
+++ b/tox.ini
6e715b
@@ -17,6 +17,3 @@ setenv =
6e715b
     RUN_PYTEST_EXTRA_ARGS = -v
6e715b
     RUN_FLAKE8_EXTRA_ARGS = --exclude tests/ensure_provider_tests.py,scripts/print_all_options.py,tests/network/ensure_provider_tests.py,.svn,CVS,.bzr,.hg,.git,__pycache__,.tox,.eggs,*.egg
6e715b
     LSR_PUBLISH_COVERAGE = normal
6e715b
-
6e715b
-[testenv:shellcheck]
6e715b
-commands = bash -c 'echo shellcheck is currently not enabled - please fix this'
6e715b
-- 
6e715b
2.30.2
6e715b