From c6b4521abff24af705ac98bb38ea4c11a3501092 Mon Sep 17 00:00:00 2001 From: Alexandre Detiste Date: Sun, 17 Mar 2024 20:28:48 +0100 Subject: [PATCH] replace old "mock" by "unittest.mock" Signed-off-by: Alexandre Detiste --- .github/workflows/test.yml | 2 +- setup.py | 1 - tests/interfaces/test_ipmitool.py | 3 ++- tests/test_helper.py | 2 +- tests/test_hpm.py | 2 +- tests/test_ipmi.py | 3 ++- tests/test_ipmitool.py | 2 +- tests/test_sel.py | 8 ++++---- tests/test_sensor.py | 4 ++-- 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0d649cb..2e0d4ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies - run: pip install python-coveralls coverage pytest pytest-cov mock flake8 + run: pip install python-coveralls coverage pytest pytest-cov flake8 # - name: Setup and run tests # run: python setup.py test diff --git a/setup.py b/setup.py index 92ea78b..f8f7a3c 100644 --- a/setup.py +++ b/setup.py @@ -72,7 +72,6 @@ def git_pep440_version(): test_suite='tests', tests_require=[ 'pytest', - 'mock', ], install_requires=[ ], diff --git a/tests/interfaces/test_ipmitool.py b/tests/interfaces/test_ipmitool.py index 3ff665d..c73161b 100644 --- a/tests/interfaces/test_ipmitool.py +++ b/tests/interfaces/test_ipmitool.py @@ -1,8 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from unittest.mock import MagicMock + import pytest -from mock import MagicMock from pyipmi.errors import IpmiTimeoutError, IpmiConnectionError from pyipmi.interfaces import Ipmitool diff --git a/tests/test_helper.py b/tests/test_helper.py index 25b48bb..44ea2f3 100644 --- a/tests/test_helper.py +++ b/tests/test_helper.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from mock import MagicMock, call +from unittest.mock import MagicMock, call from pyipmi.helper import clear_repository_helper from pyipmi.msgs.constants import (REPOSITORY_ERASURE_COMPLETED, diff --git a/tests/test_hpm.py b/tests/test_hpm.py index 9fd450d..6918346 100644 --- a/tests/test_hpm.py +++ b/tests/test_hpm.py @@ -17,7 +17,7 @@ PROPERTY_DEFERRED_VERSION) -class TestComponentProperty(object): +class TestComponentProperty: def test_general(self): prop = ComponentProperty().from_data(PROPERTY_GENERAL_PROPERTIES, b'\xaa') assert type(prop) is ComponentPropertyGeneral diff --git a/tests/test_ipmi.py b/tests/test_ipmi.py index 71d533b..e0072d2 100644 --- a/tests/test_ipmi.py +++ b/tests/test_ipmi.py @@ -1,8 +1,9 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- +from unittest.mock import MagicMock + import pytest -from mock import MagicMock from pyipmi import interfaces, create_connection, Target, Routing from pyipmi.errors import CompletionCodeError, RetryError diff --git a/tests/test_ipmitool.py b/tests/test_ipmitool.py index 1c1d3bd..ef270b5 100644 --- a/tests/test_ipmitool.py +++ b/tests/test_ipmitool.py @@ -3,7 +3,7 @@ from pyipmi.ipmitool import parse_interface_options -class TestParseInterfaceOptions(object): +class TestParseInterfaceOptions: def test_options_aardvark(self): options = parse_interface_options('aardvark', 'serial=1234') assert options['serial_number'] == '1234' diff --git a/tests/test_sel.py b/tests/test_sel.py index 2cc822e..a386f86 100644 --- a/tests/test_sel.py +++ b/tests/test_sel.py @@ -1,14 +1,14 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from mock import MagicMock +from unittest.mock import MagicMock from pyipmi import interfaces, create_connection from pyipmi.msgs.registry import create_response_by_name from pyipmi.sel import SelEntry, SelInfo -class TestSel(object): +class TestSel: def test_get_sel_entries(self): rsps = list() @@ -36,7 +36,7 @@ def test_get_sel_entries(self): assert len(entries) == 2 -class TestSelInfo(object): +class TestSelInfo: rsp = create_response_by_name('GetSelInfo') rsp.version = 1 rsp.entries = 1023 @@ -108,7 +108,7 @@ class TestSelInfo(object): assert 'overflow_flag' in info.operation_support -class TestSelEnty(object): +class TestSelEnty: def test_from_data(self): data = [0xff, 0x03, 0x02, 0xf7, 0x61, 0xef, 0x52, 0x7e, diff --git a/tests/test_sensor.py b/tests/test_sensor.py index ac567d0..d969c1f 100644 --- a/tests/test_sensor.py +++ b/tests/test_sensor.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from mock import MagicMock +from unittest.mock import MagicMock from pyipmi import interfaces, create_connection from pyipmi.msgs.sensor import (SetSensorThresholdsRsp, GetSensorThresholdsRsp, @@ -10,7 +10,7 @@ SENSOR_TYPE_MODULE_HOT_SWAP) -class TestSensor(object): +class TestSensor: def setup_method(self): self.mock_send_recv = MagicMock()