From 33c3a5ff81232ed1db323fd018db75ff389928e7 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Thu, 28 May 2026 14:35:53 +0200 Subject: [PATCH] tests: remove useless c23 module --- iotlabcli/tests/auth_parser_test.py | 5 +-- iotlabcli/tests/auth_test.py | 5 +-- iotlabcli/tests/c23.py | 47 ----------------------- iotlabcli/tests/common_parser_test.py | 7 ++-- iotlabcli/tests/experiment_parser_test.py | 4 +- iotlabcli/tests/experiment_test.py | 4 +- iotlabcli/tests/helpers_test.py | 3 +- iotlabcli/tests/main_parser_test.py | 12 +----- iotlabcli/tests/my_mock.py | 3 +- iotlabcli/tests/node_parser_test.py | 4 +- iotlabcli/tests/node_test.py | 3 +- iotlabcli/tests/profile_parser_test.py | 4 +- iotlabcli/tests/rest_test.py | 4 +- iotlabcli/tests/robot_parser_test.py | 4 +- iotlabcli/tests/status_parser_test.py | 4 +- tox.ini | 1 + 16 files changed, 28 insertions(+), 86 deletions(-) delete mode 100644 iotlabcli/tests/c23.py diff --git a/iotlabcli/tests/auth_parser_test.py b/iotlabcli/tests/auth_parser_test.py index 507cc7a..5e6e601 100644 --- a/iotlabcli/tests/auth_parser_test.py +++ b/iotlabcli/tests/auth_parser_test.py @@ -23,12 +23,11 @@ import sys import unittest +from unittest.mock import patch import iotlabcli.parser.auth as auth_parser from iotlabcli import auth -from .c23 import patch - # pylint: disable=missing-docstring,too-many-public-methods @@ -84,7 +83,7 @@ def test_main(self, getpass_m, store_m, ssh_key_m, ssh_keys_m): # List ssh key with -u/-p options ssh_key_m.reset_mock() - ssh_keys_m.call_count = 0 + ssh_keys_m.reset_mock() api.check_credential.return_value = True store_m.return_value = "Written" auth_parser.main(["-u", "super_user", "-p", "password", "--list-ssh-keys"]) diff --git a/iotlabcli/tests/auth_test.py b/iotlabcli/tests/auth_test.py index c4fb3d4..ec02e1f 100644 --- a/iotlabcli/tests/auth_test.py +++ b/iotlabcli/tests/auth_test.py @@ -25,11 +25,10 @@ import os import unittest +from unittest.mock import mock_open, patch from iotlabcli import auth -from .c23 import mock_open, patch - TEST_RC_FILE = "test_iotlabrc_file" @@ -133,7 +132,7 @@ def test_add_ssh_key(self, m_api_class): test_keys["sshkeys"].append(TEST_SSHKEYS) api.set_ssh_keys.assert_called_with(test_keys) - api.get_ssh_keys.call_count = 0 + api.get_ssh_keys.reset_mock() # Cannot add a key that is already stored (here it's in test_keys) self.assertRaises(ValueError, auth.add_ssh_key, TEST_SSH_IDENTITY_FILE) api.get_ssh_keys.assert_called_once() diff --git a/iotlabcli/tests/c23.py b/iotlabcli/tests/c23.py deleted file mode 100644 index 8f82256..0000000 --- a/iotlabcli/tests/c23.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding:utf-8 -*- - -# This file is a part of IoT-LAB cli-tools -# Copyright (C) 2015 INRIA (Contact: admin@iot-lab.info) -# Contributor(s) : see AUTHORS file -# -# This software is governed by the CeCILL license under French law -# and abiding by the rules of distribution of free software. You can use, -# modify and/ or redistribute the software under the terms of the CeCILL -# license as circulated by CEA, CNRS and INRIA at the following URL -# http://www.cecill.info. -# -# As a counterpart to the access to the source code and rights to copy, -# modify and redistribute granted by the license, users are provided only -# with a limited warranty and the software's author, the holder of the -# economic rights, and the successive licensors have only limited -# liability. -# -# The fact that you are presently reading this means that you have had -# knowledge of the CeCILL license and that you accept its terms. - -"""Tests Compatibility imports for python2 and python3.""" - - -# pylint: disable=import-error,no-name-in-module -# pylint: disable=unused-import -# pylint: disable=ungrouped-imports -# pylint: disable=wrong-import-order -# flake8: noqa - -from sys import version_info - -if version_info[0] == 2: # pragma: no cover - # python2 - import mock - from cStringIO import StringIO - from urllib2 import HTTPError -elif version_info[0] == 3: # pragma: no cover - # python3 - from io import StringIO - from unittest import mock - from urllib.error import HTTPError -else: # pragma: no cover - raise ValueError(f"Unknown python version {version_info!r}") - -# pylint:disable=wrong-import-position -from mock import Mock, mock_open, patch # noqa diff --git a/iotlabcli/tests/common_parser_test.py b/iotlabcli/tests/common_parser_test.py index 17cf13a..745a287 100644 --- a/iotlabcli/tests/common_parser_test.py +++ b/iotlabcli/tests/common_parser_test.py @@ -25,14 +25,15 @@ import argparse import sys import unittest +from io import StringIO +from unittest.mock import Mock, patch +from urllib.error import HTTPError from iotlabcli.parser import common from iotlabcli.parser.common import print_result from iotlabcli.tests.my_mock import api_mock, api_mock_stop -from .c23 import HTTPError, Mock, StringIO, patch - -BUILTIN = "builtins" if sys.version_info[0] == 3 else "__builtin__" +BUILTIN = "builtins" class TestCommonParser(unittest.TestCase): diff --git a/iotlabcli/tests/experiment_parser_test.py b/iotlabcli/tests/experiment_parser_test.py index 966eb83..7c0e2b9 100644 --- a/iotlabcli/tests/experiment_parser_test.py +++ b/iotlabcli/tests/experiment_parser_test.py @@ -25,14 +25,14 @@ import argparse import unittest +from io import StringIO +from unittest.mock import patch import iotlabcli.parser.experiment as experiment_parser from iotlabcli import experiment from iotlabcli.tests import resource_file from iotlabcli.tests.my_mock import MainMock -from .c23 import StringIO, patch - class TestMainInfoParser(MainMock): """Test experiment.parser.""" diff --git a/iotlabcli/tests/experiment_test.py b/iotlabcli/tests/experiment_test.py index 9192b7a..23189fe 100644 --- a/iotlabcli/tests/experiment_test.py +++ b/iotlabcli/tests/experiment_test.py @@ -33,12 +33,12 @@ import json import unittest +from unittest import mock +from unittest.mock import mock_open, patch from iotlabcli import experiment, helpers, rest, tests from iotlabcli.tests.my_mock import API_RET, CommandMock, RequestRet -from .c23 import mock, mock_open, patch - SCRIPTS = { "script.sh": (b'#! /bin/sh\necho "script.sh"\n'), "script_2.sh": (b'#! /bin/sh\necho "script_2.sh"\n'), diff --git a/iotlabcli/tests/helpers_test.py b/iotlabcli/tests/helpers_test.py index 5c5bff0..0d9b77a 100644 --- a/iotlabcli/tests/helpers_test.py +++ b/iotlabcli/tests/helpers_test.py @@ -25,14 +25,13 @@ import sys import unittest import warnings +from unittest.mock import patch import pytest from iotlabcli import helpers from iotlabcli.tests import my_mock -from .c23 import patch - class TestHelpers(unittest.TestCase): """Test the iotlabcli.helpers module""" diff --git a/iotlabcli/tests/main_parser_test.py b/iotlabcli/tests/main_parser_test.py index 8177dc4..1cf6514 100644 --- a/iotlabcli/tests/main_parser_test.py +++ b/iotlabcli/tests/main_parser_test.py @@ -24,13 +24,12 @@ import argparse import subprocess import sys +from unittest.mock import patch import pytest import iotlabcli.parser.main as main_parser -from .c23 import patch, version_info - @pytest.mark.parametrize( "entry", ["auth", "experiment", "node", "profile", "robot", "status"] @@ -70,14 +69,7 @@ def test_help(argv, exc): except ImportError: iotlabsshcli = None -try: - import iotlabaggregator - - if version_info[0] != 2: - # pylint: disable=invalid-name - iotlabaggregator = None # noqa -except (ImportError, TypeError): - iotlabaggregator = None +iotlabaggregator = None # pylint: disable=invalid-name try: import oml_plot_tools diff --git a/iotlabcli/tests/my_mock.py b/iotlabcli/tests/my_mock.py index 38e3402..badf120 100644 --- a/iotlabcli/tests/my_mock.py +++ b/iotlabcli/tests/my_mock.py @@ -24,13 +24,12 @@ import json import sys import unittest +from unittest.mock import Mock, patch from iotlabcli import experiment from iotlabcli.helpers import json_dumps from iotlabcli.rest import Api -from .c23 import Mock, patch - API_RET = {"result": "test"} diff --git a/iotlabcli/tests/node_parser_test.py b/iotlabcli/tests/node_parser_test.py index 3fc3d79..2bc3ea8 100644 --- a/iotlabcli/tests/node_parser_test.py +++ b/iotlabcli/tests/node_parser_test.py @@ -21,11 +21,11 @@ """Test the iotlabcli.parser.node module""" +from unittest.mock import patch + import iotlabcli.parser.node as node_parser from iotlabcli.tests.my_mock import MainMock -from .c23 import patch - # pylint: disable=too-many-public-methods # pylint: disable=too-few-public-methods diff --git a/iotlabcli/tests/node_test.py b/iotlabcli/tests/node_test.py index ff0de3d..dca2817 100644 --- a/iotlabcli/tests/node_test.py +++ b/iotlabcli/tests/node_test.py @@ -26,12 +26,11 @@ # pylint: disable=no-member,maybe-no-member,too-many-statements import json import unittest +from unittest.mock import patch from iotlabcli import node from iotlabcli.tests import my_mock -from .c23 import patch - class TestNode(unittest.TestCase): """Test the 'iotlabcli.node' module""" diff --git a/iotlabcli/tests/profile_parser_test.py b/iotlabcli/tests/profile_parser_test.py index 3991191..d82d76e 100644 --- a/iotlabcli/tests/profile_parser_test.py +++ b/iotlabcli/tests/profile_parser_test.py @@ -24,12 +24,12 @@ # Mock object not being recognized # pylint: disable=no-member,maybe-no-member +from unittest.mock import patch + import iotlabcli.parser.profile as profile_parser import iotlabcli.profile from iotlabcli.tests.my_mock import MainMock -from .c23 import patch - class TestMainProfileParser(MainMock): def test_main_add_parser(self): diff --git a/iotlabcli/tests/rest_test.py b/iotlabcli/tests/rest_test.py index a017b60..43cb140 100644 --- a/iotlabcli/tests/rest_test.py +++ b/iotlabcli/tests/rest_test.py @@ -25,13 +25,13 @@ # pylint: disable=protected-access import json import unittest +from unittest.mock import patch +from urllib.error import HTTPError from iotlabcli import rest from iotlabcli.helpers import json_dumps from iotlabcli.tests.my_mock import RequestRet -from .c23 import HTTPError, patch - class TestRest(unittest.TestCase): """Test the iotlabcli.rest module diff --git a/iotlabcli/tests/robot_parser_test.py b/iotlabcli/tests/robot_parser_test.py index 3baeacd..7ffa472 100644 --- a/iotlabcli/tests/robot_parser_test.py +++ b/iotlabcli/tests/robot_parser_test.py @@ -22,11 +22,11 @@ """Test the iotlabcli.parser.robot module""" +from unittest.mock import patch + import iotlabcli.parser.robot as robot_parser from iotlabcli.tests.my_mock import MainMock -from .c23 import patch - # pylint: disable=too-many-public-methods # pylint: disable=too-few-public-methods diff --git a/iotlabcli/tests/status_parser_test.py b/iotlabcli/tests/status_parser_test.py index 04df128..96cf204 100644 --- a/iotlabcli/tests/status_parser_test.py +++ b/iotlabcli/tests/status_parser_test.py @@ -21,11 +21,11 @@ """Test the iotlabcli.parser.status module""" +from unittest.mock import patch + import iotlabcli.parser.status as status_parser from iotlabcli.tests.my_mock import MainMock -from .c23 import patch - @patch("iotlabcli.status.status_command") class TestMainStatusParser(MainMock): diff --git a/tox.ini b/tox.ini index 50ac1cc..65702c3 100644 --- a/tox.ini +++ b/tox.ini @@ -23,6 +23,7 @@ deps= git+https://github.com/iot-lab/oml-plot-tools.git#egg=oml_plot_tools git+https://github.com/iot-lab/ssh-cli-tools.git#egg=iotlabsshcli git+https://github.com/iot-lab/aggregation-tools.git#egg=iotlabaggregator + -rtests_utils/test-requirements.txt commands= {[testenv:tests]commands}