Skip to content

Commit

Permalink
replace old "mock" by "unittest.mock"
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Detiste <alexandre.detiste@gmail.com>
  • Loading branch information
a-detiste committed Mar 17, 2024
1 parent 8bf967b commit c6b4521
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion setup.py
Expand Up @@ -72,7 +72,6 @@ def git_pep440_version():
test_suite='tests',
tests_require=[
'pytest',
'mock',
],
install_requires=[
],
Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down
2 changes: 1 addition & 1 deletion 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,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hpm.py
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ipmitool.py
Expand Up @@ -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'
Expand Down
8 changes: 4 additions & 4 deletions 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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions 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,
Expand All @@ -10,7 +10,7 @@
SENSOR_TYPE_MODULE_HOT_SWAP)


class TestSensor(object):
class TestSensor:

def setup_method(self):
self.mock_send_recv = MagicMock()
Expand Down

0 comments on commit c6b4521

Please sign in to comment.