From b3ec1d0c643f89e30d05e8ce307610012984ba95 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Mon, 17 Jun 2019 09:28:20 -0400 Subject: [PATCH] Plugin interfaces: port to Python 3 ABC syntax And test that the interface (only) classes can not be used directly. Signed-off-by: Cleber Rosa --- avocado/core/plugin_interfaces.py | 4 +- selftests/unit/test_plugin_interfaces.py | 56 ++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 selftests/unit/test_plugin_interfaces.py diff --git a/avocado/core/plugin_interfaces.py b/avocado/core/plugin_interfaces.py index 6bb194df..8ab02bb1 100644 --- a/avocado/core/plugin_interfaces.py +++ b/avocado/core/plugin_interfaces.py @@ -16,9 +16,7 @@ import abc -class Plugin: - - __metaclass__ = abc.ABCMeta +class Plugin(metaclass=abc.ABCMeta): """ Base for all plugins diff --git a/selftests/unit/test_plugin_interfaces.py b/selftests/unit/test_plugin_interfaces.py new file mode 100644 index 00000000..2bc2769c --- /dev/null +++ b/selftests/unit/test_plugin_interfaces.py @@ -0,0 +1,56 @@ +import unittest + +from avocado.core import plugin_interfaces + + +class Plugin(unittest.TestCase): + + def test_instantiate_settings(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.Settings() + + def test_instantiate_cli(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.CLI() + + def test_instantiate_cli_cmd(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.CLICmd() + + def test_instantiate_job_pre(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.JobPre() + + def test_instantiate_job_post(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.JobPost() + + def test_instantiate_result(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.Result() + + def test_instantiate_job_pre_tests(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.JobPreTests() + + def test_instantiate_job_post_tests(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.JobPostTests() + + def test_instantiate_result_events(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.ResultEvents() + + def test_instantiate_varianter(self): + with self.assertRaises(TypeError): + # pylint: disable=E0110 + plugin_interfaces.Varianter() -- GitLab