From 52d9078836ebd9ea0df2fc2afe228aa4f48f3f8c Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Tue, 12 Nov 2024 17:46:05 -0600 Subject: [PATCH] enable pyupgrade via ruff to Python 3.7 Upgrade our syntax to Python 3.7 using pyupgrade support via ruff. Change-Id: I475eed8abbfff0717211605364482ab942c69369 Signed-off-by: Doug Goldstein --- pyproject.toml | 5 ++++ releasenotes/source/conf.py | 1 - sushy/__init__.py | 1 - sushy/auth.py | 11 ++++---- sushy/connector.py | 7 +++-- sushy/exceptions.py | 6 ++--- sushy/main.py | 4 +-- sushy/resources/base.py | 26 +++++++++---------- sushy/resources/chassis/chassis.py | 4 +-- sushy/resources/common.py | 3 +-- .../compositionservice/compositionservice.py | 2 +- .../compositionservice/resourceblock.py | 4 +-- .../compositionservice/resourcezone.py | 4 +-- .../eventservice/eventdestination.py | 4 +-- sushy/resources/eventservice/eventservice.py | 2 +- sushy/resources/fabric/fabric.py | 4 +-- sushy/resources/manager/manager.py | 4 +-- sushy/resources/oem/base.py | 4 +-- sushy/resources/oem/common.py | 8 +++--- sushy/resources/sessionservice/session.py | 4 +-- .../sessionservice/sessionservice.py | 2 +- sushy/resources/settings.py | 6 ++--- sushy/resources/system/bios.py | 2 +- sushy/resources/system/processor.py | 4 +-- sushy/resources/system/secure_boot.py | 2 +- .../resources/system/secure_boot_database.py | 2 +- sushy/resources/system/storage/controller.py | 2 +- sushy/resources/system/system.py | 4 +-- sushy/resources/taskservice/task.py | 2 +- sushy/resources/taskservice/taskservice.py | 2 +- .../updateservice/softwareinventory.py | 4 +-- .../resources/updateservice/updateservice.py | 2 +- sushy/taskmonitor.py | 8 +++--- sushy/tests/unit/base.py | 1 - .../unit/resources/chassis/test_chassis.py | 5 ++-- .../unit/resources/chassis/test_power.py | 3 +-- .../unit/resources/chassis/test_thermal.py | 3 +-- .../test_compositionservice.py | 2 +- .../compositionservice/test_resourceblock.py | 4 +-- .../compositionservice/test_resourcezone.py | 4 +-- .../eventservice/test_evendestination.py | 8 +++--- .../eventservice/test_eventservice.py | 2 +- .../unit/resources/fabric/test_endpoint.py | 2 +- .../unit/resources/fabric/test_fabric.py | 7 +++-- .../unit/resources/manager/test_manager.py | 8 +++--- .../resources/manager/test_virtual_media.py | 6 ++--- sushy/tests/unit/resources/oem/test_common.py | 4 +-- sushy/tests/unit/resources/oem/test_fake.py | 4 +-- .../registry/test_attribute_registry.py | 2 +- .../registry/test_message_registry.py | 2 +- .../registry/test_message_registry_file.py | 6 ++--- .../resources/sessionservice/test_session.py | 4 +-- .../sessionservice/test_sessionservice.py | 2 +- .../resources/system/network/test_adapter.py | 4 +-- .../system/network/test_device_function.py | 4 +-- .../resources/system/network/test_port.py | 4 +-- .../system/storage/test_controller.py | 4 +-- .../resources/system/storage/test_drive.py | 2 +- .../resources/system/storage/test_storage.py | 4 +-- .../resources/system/storage/test_volume.py | 4 +-- .../tests/unit/resources/system/test_bios.py | 4 +-- .../system/test_ethernet_interfaces.py | 4 +-- .../tests/unit/resources/system/test_port.py | 4 +-- .../unit/resources/system/test_processor.py | 4 +-- .../unit/resources/system/test_secure_boot.py | 2 +- .../system/test_secure_boot_database.py | 6 ++--- .../resources/system/test_simple_storage.py | 4 +-- .../unit/resources/system/test_system.py | 14 +++++----- .../unit/resources/taskservice/test_task.py | 4 +-- .../resources/taskservice/test_taskservice.py | 2 +- sushy/tests/unit/resources/test_base.py | 14 +++++----- sushy/tests/unit/resources/test_settings.py | 2 +- .../updateservice/test_softwareinventory.py | 4 +-- .../updateservice/test_updateservice.py | 4 +-- sushy/tests/unit/test_auth.py | 6 ++--- sushy/tests/unit/test_connector.py | 8 +++--- sushy/tests/unit/test_main.py | 4 +-- sushy/tests/unit/test_taskmonitor.py | 2 +- sushy/tests/unit/test_utils.py | 4 +-- sushy/utils.py | 2 +- 80 files changed, 171 insertions(+), 182 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3ada8694..995245c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,10 @@ build-backend = "pbr.build" [tool.doc8] ignore = ["D001"] +[tool.ruff] +line-length = 79 +target-version = "py37" + [tool.ruff.lint] select = [ "E", # pycodestyle (error) @@ -12,6 +16,7 @@ select = [ "G", # flake8-logging-format "LOG", # flake8-logging "S", # flake8-bandit + "UP", # pyupgrade ] [tool.ruff.lint.per-file-ignores] diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index a4774b93..95a572b2 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/sushy/__init__.py b/sushy/__init__.py index d433dfb6..d92aafbe 100644 --- a/sushy/__init__.py +++ b/sushy/__init__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain diff --git a/sushy/auth.py b/sushy/auth.py index ad73ad86..56c37f9b 100644 --- a/sushy/auth.py +++ b/sushy/auth.py @@ -20,7 +20,7 @@ from sushy import exceptions LOG = logging.getLogger(__name__) -class AuthBase(object, metaclass=abc.ABCMeta): +class AuthBase(metaclass=abc.ABCMeta): def __init__(self, username=None, password=None): """A class representing a base Sushy authentication mechanism @@ -129,8 +129,7 @@ class SessionAuth(AuthBase): self._session_auth_previously_successful = False """Our reminder for tracking if session auth has previously worked.""" - super(SessionAuth, self).__init__(username, - password) + super().__init__(username, password) def get_session_key(self): """Returns the session key. @@ -224,7 +223,7 @@ class SessionAuth(AuthBase): class SessionOrBasicAuth(SessionAuth): def __init__(self, username=None, password=None): - super(SessionOrBasicAuth, self).__init__(username, password) + super().__init__(username, password) self.basic_auth = BasicAuth(username=username, password=password) def _fallback_to_basic_authentication(self): @@ -241,7 +240,7 @@ class SessionOrBasicAuth(SessionAuth): """ try: # Attempt session based authentication - super(SessionOrBasicAuth, self)._do_authenticate() + super()._do_authenticate() except exceptions.AccessError as e: if (not self.can_refresh_session() and not self._session_auth_previously_successful): @@ -297,4 +296,4 @@ class SessionOrBasicAuth(SessionAuth): we simply return our BasicAuthentication requests.Session. """ if self.can_refresh_session(): - super(SessionOrBasicAuth, self).refresh_session() + super().refresh_session() diff --git a/sushy/connector.py b/sushy/connector.py index c1bcff03..b3e18044 100644 --- a/sushy/connector.py +++ b/sushy/connector.py @@ -29,7 +29,7 @@ from sushy import utils LOG = logging.getLogger(__name__) -class Connector(object): +class Connector: def __init__( self, url, username=None, password=None, verify=True, @@ -293,9 +293,8 @@ class Connector(object): raise if blocking and response.status_code == 202: if not response.headers.get('Location'): - m = ('HTTP response for %(method)s request to %(url)s ' - 'returned status 202, but no Location header' - % {'method': method, 'url': url}) + m = (f'HTTP response for {method} request to {url} ' + 'returned status 202, but no Location header') raise exceptions.ConnectionError(url=url, error=m) mon = TaskMonitor.from_response(self, response, path) diff --git a/sushy/exceptions.py b/sushy/exceptions.py index 74bb2962..63bb416d 100644 --- a/sushy/exceptions.py +++ b/sushy/exceptions.py @@ -31,7 +31,7 @@ class SushyError(Exception): if self.message and kwargs: self.message = self.message % kwargs - super(SushyError, self).__init__(self.message) + super().__init__(self.message) class ConnectionError(SushyError): @@ -116,13 +116,13 @@ class HTTPError(SushyError): self.extended_info = self.body.get('@Message.ExtendedInfo') message = self._get_most_severe_msg(self.extended_info or [{}]) self.detail = message or self.detail - error = '%s: %s' % (self.code, self.detail or 'unknown error.') + error = '{}: {}'.format(self.code, self.detail or 'unknown error.') kwargs = {'method': method, 'url': url, 'code': self.status_code, 'error': error, 'ext_info': self.extended_info} LOG.debug('HTTP response for %(method)s %(url)s: ' 'status code: %(code)s, error: %(error)s, ' 'extended: %(ext_info)s', kwargs) - super(HTTPError, self).__init__(**kwargs) + super().__init__(**kwargs) @staticmethod def _get_most_severe_msg(extended_info): diff --git a/sushy/main.py b/sushy/main.py index 249a9a96..a6fe4a5a 100644 --- a/sushy/main.py +++ b/sushy/main.py @@ -198,7 +198,7 @@ class Sushy(base.ResourceBase): password=password) self._auth = auth - super(Sushy, self).__init__( + super().__init__( connector or sushy_connector.Connector( base_url, verify=verify, server_side_retries=server_side_retries, @@ -227,7 +227,7 @@ class Sushy(base.ResourceBase): :param json_doc: parsed JSON document in form of Python types """ - super(Sushy, self)._parse_attributes(json_doc) + super()._parse_attributes(json_doc) self.redfish_version = json_doc.get('RedfishVersion') def get_system_collection(self): diff --git a/sushy/resources/base.py b/sushy/resources/base.py index b8a8aebd..b3b81a30 100644 --- a/sushy/resources/base.py +++ b/sushy/resources/base.py @@ -32,7 +32,7 @@ from sushy import utils LOG = logging.getLogger(__name__) -class Field(object): +class Field: """Definition for fields fetched from JSON.""" def __init__(self, path, required=False, default=None, @@ -139,7 +139,7 @@ class CompositeField(collections.abc.Mapping, Field, metaclass=abc.ABCMeta): """Base class for fields consisting of several sub-fields.""" def __init__(self, *args, **kwargs): - super(CompositeField, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._subfields = dict(_collect_fields(self)) def _load(self, body, resource, nested_in=None): @@ -151,7 +151,7 @@ class CompositeField(collections.abc.Mapping, Field, metaclass=abc.ABCMeta): :returns: a new object with sub-fields attached to it. """ nested_in = (nested_in or []) + self._path - value = super(CompositeField, self)._load(body, resource) + value = super()._load(body, resource) if value is None: return None @@ -185,7 +185,7 @@ class ListField(Field): """Base class for fields consisting of a list of several sub-fields.""" def __init__(self, *args, **kwargs): - super(ListField, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._subfields = dict(_collect_fields(self)) def _load(self, body, resource, nested_in=None): @@ -197,7 +197,7 @@ class ListField(Field): :returns: a new list object containing subfields. """ nested_in = (nested_in or []) + self._path - values = super(ListField, self)._load(body, resource) + values = super()._load(body, resource) if values is None: return None @@ -227,7 +227,7 @@ class DictionaryField(Field): """Base class for fields consisting of dictionary of several sub-fields.""" def __init__(self, *args, **kwargs): - super(DictionaryField, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._subfields = dict(_collect_fields(self)) def _load(self, body, resource, nested_in=None): @@ -239,7 +239,7 @@ class DictionaryField(Field): :returns: a new dictionary object containing subfields. """ nested_in = (nested_in or []) + self._path - values = super(DictionaryField, self)._load(body, resource) + values = super()._load(body, resource) if values is None: return None @@ -288,7 +288,7 @@ class MappedField(Field): raise TypeError("The mapping argument must be a mapping or " "an enumeration") - super(MappedField, self).__init__( + super().__init__( field, required=required, default=default, adapter=adapter) @@ -323,7 +323,7 @@ class MappedListField(Field): "an enumeration") self._mapping_adapter = adapter - super(MappedListField, self).__init__( + super().__init__( field, required=required, default=default, adapter=lambda x: x) @@ -336,7 +336,7 @@ class MappedListField(Field): :returns: a new list object containing the mapped values. """ nested_in = (nested_in or []) + self._path - values = super(MappedListField, self)._load(body, resource) + values = super()._load(body, resource) if values is None: return @@ -375,7 +375,7 @@ class MessageListField(ListField): """ -class FieldData(object): +class FieldData: """Contains data to be used when constructing Fields""" def __init__(self, status_code, headers, json_doc): @@ -400,7 +400,7 @@ class FieldData(object): return self._json_doc -class AbstractDataReader(object, metaclass=abc.ABCMeta): +class AbstractDataReader(metaclass=abc.ABCMeta): def set_connection(self, connector, path): """Sets mandatory connection parameters @@ -506,7 +506,7 @@ def get_reader(connector, path, reader=None): return reader -class ResourceBase(object, metaclass=abc.ABCMeta): +class ResourceBase(metaclass=abc.ABCMeta): redfish_version = None """The Redfish version""" diff --git a/sushy/resources/chassis/chassis.py b/sushy/resources/chassis/chassis.py index a2930b74..59786a60 100644 --- a/sushy/resources/chassis/chassis.py +++ b/sushy/resources/chassis/chassis.py @@ -152,7 +152,7 @@ class Chassis(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(Chassis, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -325,6 +325,6 @@ class ChassisCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ChassisCollection, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/common.py b/sushy/resources/common.py index e0929c11..2560ee21 100644 --- a/sushy/resources/common.py +++ b/sushy/resources/common.py @@ -25,8 +25,7 @@ class IdRefField(base.CompositeField): class OperationApplyTimeSupportField(base.CompositeField): def __init__(self): - super(OperationApplyTimeSupportField, self).__init__( - path="@Redfish.OperationApplyTimeSupport") + super().__init__(path="@Redfish.OperationApplyTimeSupport") maintenance_window_duration_in_seconds = base.Field( 'MaintenanceWindowDurationInSeconds', adapter=int) diff --git a/sushy/resources/compositionservice/compositionservice.py b/sushy/resources/compositionservice/compositionservice.py index 94adf452..c917d072 100644 --- a/sushy/resources/compositionservice/compositionservice.py +++ b/sushy/resources/compositionservice/compositionservice.py @@ -62,7 +62,7 @@ class CompositionService(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(CompositionService, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/compositionservice/resourceblock.py b/sushy/resources/compositionservice/resourceblock.py index 684573f7..4912e8fc 100644 --- a/sushy/resources/compositionservice/resourceblock.py +++ b/sushy/resources/compositionservice/resourceblock.py @@ -86,7 +86,7 @@ class ResourceBlock(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ResourceBlock, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -115,6 +115,6 @@ class ResourceBlockCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ResourceBlockCollection, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/compositionservice/resourcezone.py b/sushy/resources/compositionservice/resourcezone.py index f77c4aff..5257dfe2 100644 --- a/sushy/resources/compositionservice/resourcezone.py +++ b/sushy/resources/compositionservice/resourcezone.py @@ -66,7 +66,7 @@ class ResourceZone(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ResourceZone, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -95,6 +95,6 @@ class ResourceZoneCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ResourceZoneCollection, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/eventservice/eventdestination.py b/sushy/resources/eventservice/eventdestination.py index 2e099b00..db1977b7 100644 --- a/sushy/resources/eventservice/eventdestination.py +++ b/sushy/resources/eventservice/eventdestination.py @@ -65,7 +65,7 @@ class EventDestination(base.ResourceBase): that needs registries to parse messages. :param root: Sushy root object. Empty for Sushy root itself. """ - super(EventDestination, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -102,7 +102,7 @@ class EventDestinationCollection(base.ResourceCollectionBase): that needs registries to parse messages. :param root: Sushy root object. Empty for Sushy root itself. """ - super(EventDestinationCollection, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/eventservice/eventservice.py b/sushy/resources/eventservice/eventservice.py index b72bf43a..dc5f5a47 100644 --- a/sushy/resources/eventservice/eventservice.py +++ b/sushy/resources/eventservice/eventservice.py @@ -75,7 +75,7 @@ class EventService(base.ResourceBase): that needs registries to parse messages. :param root: Sushy root object. Empty for Sushy root itself. """ - super(EventService, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/fabric/fabric.py b/sushy/resources/fabric/fabric.py index ed6d9118..31d0a2cd 100644 --- a/sushy/resources/fabric/fabric.py +++ b/sushy/resources/fabric/fabric.py @@ -62,7 +62,7 @@ class Fabric(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(Fabric, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -93,6 +93,6 @@ class FabricCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(FabricCollection, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/manager/manager.py b/sushy/resources/manager/manager.py index 078c1fab..2194511d 100644 --- a/sushy/resources/manager/manager.py +++ b/sushy/resources/manager/manager.py @@ -97,7 +97,7 @@ class Manager(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(Manager, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -272,6 +272,6 @@ class ManagerCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ManagerCollection, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/oem/base.py b/sushy/resources/oem/base.py index 52f29517..2c4fac05 100644 --- a/sushy/resources/oem/base.py +++ b/sushy/resources/oem/base.py @@ -40,7 +40,7 @@ class OEMResourceBase(base.ResourceBase): self._parent_resource = None self._vendor_id = None - super(OEMResourceBase, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, reader=reader, root=root) @@ -79,4 +79,4 @@ class OEMResourceBase(base.ResourceBase): oem_json.update(oem_actions_json) - super(OEMResourceBase, self)._parse_attributes(oem_json) + super()._parse_attributes(oem_json) diff --git a/sushy/resources/oem/common.py b/sushy/resources/oem/common.py index 5a0b9c0e..1db1b083 100644 --- a/sushy/resources/oem/common.py +++ b/sushy/resources/oem/common.py @@ -25,7 +25,7 @@ _global_extn_mgrs_by_resource = {} def _raise(m, ep, e): raise exceptions.ExtensionError( - error='Failed to load entry point target: %(error)s' % {'error': e}) + error=f'Failed to load entry point target: {e}') def _create_extension_manager(namespace): @@ -56,10 +56,8 @@ def _create_extension_manager(namespace): 'target': extension.entry_point_target}) if not extension_manager.names(): - m = (('No extensions found for "%(resource)s" under namespace ' - '"%(namespace)s"') % - {'resource': resource_name, - 'namespace': namespace}) + m = (f'No extensions found for "{resource_name}" under namespace ' + f'"{namespace}"') LOG.error(m) raise exceptions.ExtensionError(error=m) diff --git a/sushy/resources/sessionservice/session.py b/sushy/resources/sessionservice/session.py index 18e9f057..f9f8bd82 100644 --- a/sushy/resources/sessionservice/session.py +++ b/sushy/resources/sessionservice/session.py @@ -49,7 +49,7 @@ class Session(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(Session, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -85,6 +85,6 @@ class SessionCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(SessionCollection, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/sessionservice/sessionservice.py b/sushy/resources/sessionservice/sessionservice.py index ee05dccd..6abfa3bf 100644 --- a/sushy/resources/sessionservice/sessionservice.py +++ b/sushy/resources/sessionservice/sessionservice.py @@ -60,7 +60,7 @@ class SessionService(base.ResourceBase): """ # Populating the base resource so session interactions can # occur based on the contents of it. - super(SessionService, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/settings.py b/sushy/resources/settings.py index 88ffbf98..0575e4b8 100644 --- a/sushy/resources/settings.py +++ b/sushy/resources/settings.py @@ -40,7 +40,7 @@ NO_UPDATES = 4 """No updates made""" -class SettingsUpdate(object): +class SettingsUpdate: """Contains Settings update status and details of the update""" def __init__(self, status, messages): @@ -77,7 +77,7 @@ class MaintenanceWindowField(base.CompositeField): class SettingsApplyTimeField(base.CompositeField): def __init__(self): - super(SettingsApplyTimeField, self).__init__( + super().__init__( path="@Redfish.SettingsApplyTime") apply_time = base.Field('ApplyTime', adapter=str) @@ -109,7 +109,7 @@ class SettingsField(base.CompositeField): """ def __init__(self): - super(SettingsField, self).__init__(path="@Redfish.Settings") + super().__init__(path="@Redfish.Settings") time = base.Field('Time') """Indicates the time the settings were applied to the server""" diff --git a/sushy/resources/system/bios.py b/sushy/resources/system/bios.py index 2f26662d..141cea6c 100644 --- a/sushy/resources/system/bios.py +++ b/sushy/resources/system/bios.py @@ -42,7 +42,7 @@ class Bios(base.ResourceBase): parsing messages of attribute update status :param root: Sushy root object. Empty for Sushy root itself. """ - super(Bios, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/system/processor.py b/sushy/resources/system/processor.py index cd97387d..c73b0c86 100644 --- a/sushy/resources/system/processor.py +++ b/sushy/resources/system/processor.py @@ -103,7 +103,7 @@ class Processor(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(Processor, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -169,7 +169,7 @@ class ProcessorCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ProcessorCollection, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/system/secure_boot.py b/sushy/resources/system/secure_boot.py index e1961d9a..80f1237f 100644 --- a/sushy/resources/system/secure_boot.py +++ b/sushy/resources/system/secure_boot.py @@ -142,7 +142,7 @@ class SecureBoot(base.ResourceBase): """ if not isinstance(enabled, bool): raise exceptions.InvalidParameterValueError( - "Expected a boolean for 'enabled', got %r" % enabled) + f"Expected a boolean for 'enabled', got {enabled}") etag = self._get_etag() self._conn.patch(self.path, data={'SecureBootEnable': enabled}, diff --git a/sushy/resources/system/secure_boot_database.py b/sushy/resources/system/secure_boot_database.py index 6cab0c6d..4c7b0979 100644 --- a/sushy/resources/system/secure_boot_database.py +++ b/sushy/resources/system/secure_boot_database.py @@ -110,6 +110,6 @@ class SecureBootDatabaseCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(SecureBootDatabaseCollection, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/system/storage/controller.py b/sushy/resources/system/storage/controller.py index 4535f618..c6259025 100644 --- a/sushy/resources/system/storage/controller.py +++ b/sushy/resources/system/storage/controller.py @@ -148,7 +148,7 @@ class ControllerCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(ControllerCollection, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/system/system.py b/sushy/resources/system/system.py index 002031bb..e64e2be6 100644 --- a/sushy/resources/system/system.py +++ b/sushy/resources/system/system.py @@ -175,7 +175,7 @@ class System(base.ResourceBase): that needs registries to parse messages. :param root: Sushy root object. Empty for Sushy root itself. """ - super(System, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, @@ -594,6 +594,6 @@ class SystemCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(SystemCollection, self).__init__( + super().__init__( connector, path, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/taskservice/task.py b/sushy/resources/taskservice/task.py index cd3dd598..da96414c 100644 --- a/sushy/resources/taskservice/task.py +++ b/sushy/resources/taskservice/task.py @@ -75,7 +75,7 @@ class Task(base.ResourceBase): :param field_data: the data to use populating the fields :param root: Sushy root object. Empty for Sushy root itself. """ - super(Task, self).__init__( + super().__init__( connector, identity, redfish_version, registries, json_doc=json_doc, root=root) diff --git a/sushy/resources/taskservice/taskservice.py b/sushy/resources/taskservice/taskservice.py index 08166e05..08e56041 100644 --- a/sushy/resources/taskservice/taskservice.py +++ b/sushy/resources/taskservice/taskservice.py @@ -59,7 +59,7 @@ class TaskService(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(TaskService, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/updateservice/softwareinventory.py b/sushy/resources/updateservice/softwareinventory.py index 5ab8134e..f74a25b0 100644 --- a/sushy/resources/updateservice/softwareinventory.py +++ b/sushy/resources/updateservice/softwareinventory.py @@ -70,7 +70,7 @@ class SoftwareInventory(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(SoftwareInventory, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) @@ -99,6 +99,6 @@ class SoftwareInventoryCollection(base.ResourceCollectionBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(SoftwareInventoryCollection, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/resources/updateservice/updateservice.py b/sushy/resources/updateservice/updateservice.py index e8e48ea8..42500e69 100644 --- a/sushy/resources/updateservice/updateservice.py +++ b/sushy/resources/updateservice/updateservice.py @@ -76,7 +76,7 @@ class UpdateService(base.ResourceBase): used in any resource that needs registries to parse messages :param root: Sushy root object. Empty for Sushy root itself. """ - super(UpdateService, self).__init__( + super().__init__( connector, identity, redfish_version=redfish_version, registries=registries, root=root) diff --git a/sushy/taskmonitor.py b/sushy/taskmonitor.py index c8019443..edecfd36 100644 --- a/sushy/taskmonitor.py +++ b/sushy/taskmonitor.py @@ -27,7 +27,7 @@ from sushy.resources.taskservice import task LOG = logging.getLogger(__name__) -class TaskMonitor(object): +class TaskMonitor: def __init__(self, connector, task_monitor_uri, @@ -191,10 +191,8 @@ class TaskMonitor(object): 'sleep': self.sleep_for}) time.sleep(self.sleep_for) if time.time() >= timeout_at and self.check_is_processing: - m = ('Timeout waiting for task monitor %(url)s ' - '(timeout = %(timeout)s)' - % {'url': self.task_monitor_uri, - 'timeout': timeout_sec}) + m = (f'Timeout waiting for task monitor ' + f'{self.task_monitor_uri} (timeout = {timeout_sec})') raise exceptions.ConnectionError(url=self.task_monitor_uri, error=m) diff --git a/sushy/tests/unit/base.py b/sushy/tests/unit/base.py index 97423efd..4665840f 100644 --- a/sushy/tests/unit/base.py +++ b/sushy/tests/unit/base.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Copyright 2010-2011 OpenStack Foundation # Copyright (c) 2013 Hewlett-Packard Development Company, L.P. diff --git a/sushy/tests/unit/resources/chassis/test_chassis.py b/sushy/tests/unit/resources/chassis/test_chassis.py index 243129a8..768add96 100644 --- a/sushy/tests/unit/resources/chassis/test_chassis.py +++ b/sushy/tests/unit/resources/chassis/test_chassis.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -28,7 +27,7 @@ from sushy.tests.unit import base class ChassisTestCase(base.TestCase): def setUp(self): - super(ChassisTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/chassis.json') as f: self.json_doc = json.load(f) @@ -226,7 +225,7 @@ class ChassisTestCase(base.TestCase): class ChassisCollectionTestCase(base.TestCase): def setUp(self): - super(ChassisCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'chassis_collection.json') as f: diff --git a/sushy/tests/unit/resources/chassis/test_power.py b/sushy/tests/unit/resources/chassis/test_power.py index 82135c4a..64c3310b 100644 --- a/sushy/tests/unit/resources/chassis/test_power.py +++ b/sushy/tests/unit/resources/chassis/test_power.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -24,7 +23,7 @@ from sushy.tests.unit import base class PowerTestCase(base.TestCase): def setUp(self): - super(PowerTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/power.json') as f: self.json_doc = json.load(f) diff --git a/sushy/tests/unit/resources/chassis/test_thermal.py b/sushy/tests/unit/resources/chassis/test_thermal.py index 172ee5d3..cdca5675 100644 --- a/sushy/tests/unit/resources/chassis/test_thermal.py +++ b/sushy/tests/unit/resources/chassis/test_thermal.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -24,7 +23,7 @@ from sushy.tests.unit import base class ThermalTestCase(base.TestCase): def setUp(self): - super(ThermalTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/thermal.json') as f: self.json_doc = json.load(f) diff --git a/sushy/tests/unit/resources/compositionservice/test_compositionservice.py b/sushy/tests/unit/resources/compositionservice/test_compositionservice.py index 53e3df7b..0f35a6af 100644 --- a/sushy/tests/unit/resources/compositionservice/test_compositionservice.py +++ b/sushy/tests/unit/resources/compositionservice/test_compositionservice.py @@ -24,7 +24,7 @@ from sushy.tests.unit import base class CompositionServiceTestCase(base.TestCase): def setUp(self): - super(CompositionServiceTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open( 'sushy/tests/unit/json_samples/compositionservice.json') as f: diff --git a/sushy/tests/unit/resources/compositionservice/test_resourceblock.py b/sushy/tests/unit/resources/compositionservice/test_resourceblock.py index 653f536e..371ce0e9 100644 --- a/sushy/tests/unit/resources/compositionservice/test_resourceblock.py +++ b/sushy/tests/unit/resources/compositionservice/test_resourceblock.py @@ -24,7 +24,7 @@ from sushy.tests.unit import base class ResourceBlockTestCase(base.TestCase): def setUp(self): - super(ResourceBlockTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/resourceblock.json') as f: self.json_doc = json.load(f) @@ -70,7 +70,7 @@ class ResourceBlockTestCase(base.TestCase): class ResourceBlockCollectionTestCase(base.TestCase): def setUp(self): - super(ResourceBlockCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'resourceblock_collection.json') as f: diff --git a/sushy/tests/unit/resources/compositionservice/test_resourcezone.py b/sushy/tests/unit/resources/compositionservice/test_resourcezone.py index a9c62e4b..940b67e0 100644 --- a/sushy/tests/unit/resources/compositionservice/test_resourcezone.py +++ b/sushy/tests/unit/resources/compositionservice/test_resourcezone.py @@ -23,7 +23,7 @@ from sushy.tests.unit import base class ResourceZoneTestCase(base.TestCase): def setUp(self): - super(ResourceZoneTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/resourcezone.json') as f: self.json_doc = json.load(f) @@ -59,7 +59,7 @@ class ResourceZoneTestCase(base.TestCase): class ResourceZoneCollectionTestCase(base.TestCase): def setUp(self): - super(ResourceZoneCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'resourcezone_collection.json') as f: diff --git a/sushy/tests/unit/resources/eventservice/test_evendestination.py b/sushy/tests/unit/resources/eventservice/test_evendestination.py index 3df298e8..4d71715b 100644 --- a/sushy/tests/unit/resources/eventservice/test_evendestination.py +++ b/sushy/tests/unit/resources/eventservice/test_evendestination.py @@ -20,7 +20,7 @@ from sushy.tests.unit import base class EventDestinationTestCase(base.TestCase): def setUp(self): - super(EventDestinationTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/eventdestination1.json') as f: self.json_doc = json.load(f) @@ -53,10 +53,10 @@ class EventDestinationTestCase(base.TestCase): class EventDestinationCollectionTestCase(base.TestCase): def setUp(self): - super(EventDestinationCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' - 'eventdestination_collection.json', 'r') as f: + 'eventdestination_collection.json') as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) self.eventdestination = eventdestination.EventDestinationCollection( self.conn, '/redfish/v1/EventService/Subscriptions', @@ -77,7 +77,7 @@ class EventDestinationCollectionTestCase(base.TestCase): members = self.eventdestination.get_members() calls = [ mock.call(self.eventdestination._conn, - '/redfish/v1/EventService/Subscriptions/%s' % member, + f'/redfish/v1/EventService/Subscriptions/{member}', redfish_version=self.eventdestination.redfish_version, registries=None, root=self.eventdestination.root) diff --git a/sushy/tests/unit/resources/eventservice/test_eventservice.py b/sushy/tests/unit/resources/eventservice/test_eventservice.py index 795ea63b..dc45c236 100644 --- a/sushy/tests/unit/resources/eventservice/test_eventservice.py +++ b/sushy/tests/unit/resources/eventservice/test_eventservice.py @@ -23,7 +23,7 @@ from sushy.tests.unit import base class EventServiceTestCase(base.TestCase): def setUp(self): - super(EventServiceTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/eventservice.json') as f: self.json_doc = json.load(f) diff --git a/sushy/tests/unit/resources/fabric/test_endpoint.py b/sushy/tests/unit/resources/fabric/test_endpoint.py index 32b6ddca..0f1f7289 100644 --- a/sushy/tests/unit/resources/fabric/test_endpoint.py +++ b/sushy/tests/unit/resources/fabric/test_endpoint.py @@ -22,7 +22,7 @@ from sushy.tests.unit import base class EndpointTestCase(base.TestCase): def setUp(self): - super(EndpointTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'endpoint.json') as f: diff --git a/sushy/tests/unit/resources/fabric/test_fabric.py b/sushy/tests/unit/resources/fabric/test_fabric.py index 8820f799..7aa27835 100644 --- a/sushy/tests/unit/resources/fabric/test_fabric.py +++ b/sushy/tests/unit/resources/fabric/test_fabric.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -25,7 +24,7 @@ from sushy.tests.unit import base class FabricTestCase(base.TestCase): def setUp(self): - super(FabricTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/fabric.json') as f: self.json_doc = json.load(f) @@ -87,7 +86,7 @@ class FabricTestCase(base.TestCase): self.assertIsInstance(endpts, endpoint.EndpointCollection) # On refreshing the fabric instance... - with open('sushy/tests/unit/json_samples/fabric.json', 'r') as f: + with open('sushy/tests/unit/json_samples/fabric.json') as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) self.fabric.invalidate() @@ -110,7 +109,7 @@ class FabricTestCase(base.TestCase): class FabricCollectionTestCase(base.TestCase): def setUp(self): - super(FabricCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'fabric_collection.json') as f: diff --git a/sushy/tests/unit/resources/manager/test_manager.py b/sushy/tests/unit/resources/manager/test_manager.py index e1506472..afd2a28d 100644 --- a/sushy/tests/unit/resources/manager/test_manager.py +++ b/sushy/tests/unit/resources/manager/test_manager.py @@ -27,7 +27,7 @@ from sushy.tests.unit import base class ManagerTestCase(base.TestCase): def setUp(self): - super(ManagerTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/manager.json') as f: self.json_doc = json.load(f) @@ -262,7 +262,7 @@ class ManagerTestCase(base.TestCase): self.assertIsInstance(vrt_media, virtual_media.VirtualMediaCollection) # On refreshing the manager instance... - with open('sushy/tests/unit/json_samples/manager.json', 'r') as f: + with open('sushy/tests/unit/json_samples/manager.json') as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) self.manager.invalidate() @@ -328,7 +328,7 @@ class ManagerTestCase(base.TestCase): class ManagerWithoutVirtualMedia(base.TestCase): def setUp(self): - super(ManagerWithoutVirtualMedia, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'managerv1_18.json') as f: @@ -348,7 +348,7 @@ class ManagerWithoutVirtualMedia(base.TestCase): class ManagerCollectionTestCase(base.TestCase): def setUp(self): - super(ManagerCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'manager_collection.json') as f: diff --git a/sushy/tests/unit/resources/manager/test_virtual_media.py b/sushy/tests/unit/resources/manager/test_virtual_media.py index 02a93e93..2dc52089 100644 --- a/sushy/tests/unit/resources/manager/test_virtual_media.py +++ b/sushy/tests/unit/resources/manager/test_virtual_media.py @@ -27,7 +27,7 @@ from sushy.tests.unit import base class VirtualMediaTestCase(base.TestCase): def setUp(self): - super(VirtualMediaTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.conn.get.return_value.headers = {'Allow': 'GET,HEAD'} with open('sushy/tests/unit/json_samples/' @@ -267,8 +267,8 @@ class VirtualMediaTestCase(base.TestCase): self.assertFalse(self.sys_virtual_media._is_stale) self.sys_virtual_media.eject_media() self.sys_virtual_media._conn.post.assert_called_once_with( - ("/redfish/v1/Managers/BMC/VirtualMedia/Floppy1/Actions" - "/VirtualMedia.EjectMedia")) + "/redfish/v1/Managers/BMC/VirtualMedia/Floppy1/Actions" + "/VirtualMedia.EjectMedia") self.assertTrue(self.sys_virtual_media._is_stale) def test_eject_media_fallback(self): diff --git a/sushy/tests/unit/resources/oem/test_common.py b/sushy/tests/unit/resources/oem/test_common.py index 79e35db4..9e827dba 100644 --- a/sushy/tests/unit/resources/oem/test_common.py +++ b/sushy/tests/unit/resources/oem/test_common.py @@ -32,7 +32,7 @@ class FauxResourceOEMExtension(oem_base.OEMResourceBase): class ResourceOEMCommonMethodsTestCase(base.TestCase): def setUp(self): - super(ResourceOEMCommonMethodsTestCase, self).setUp() + super().setUp() # We use ExtensionManager.make_test_instance() and instantiate the # test instance outside of the test cases in setUp. Inside of the # test cases we set this as the return value of the mocked @@ -66,7 +66,7 @@ class ResourceOEMCommonMethodsTestCase(base.TestCase): [self.contoso_extn_dup, self.faux_extn_dup])) def tearDown(self): - super(ResourceOEMCommonMethodsTestCase, self).tearDown() + super().tearDown() if oem_common._global_extn_mgrs_by_resource: oem_common._global_extn_mgrs_by_resource = {} diff --git a/sushy/tests/unit/resources/oem/test_fake.py b/sushy/tests/unit/resources/oem/test_fake.py index 2e564ee0..171aae1b 100644 --- a/sushy/tests/unit/resources/oem/test_fake.py +++ b/sushy/tests/unit/resources/oem/test_fake.py @@ -22,9 +22,9 @@ from sushy.tests.unit import base class FakeOEMSystemExtensionTestCase(base.TestCase): def setUp(self): - super(FakeOEMSystemExtensionTestCase, self).setUp() + super().setUp() self.conn = mock.MagicMock() - with open('sushy/tests/unit/json_samples/system.json', 'r') as f: + with open('sushy/tests/unit/json_samples/system.json') as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) self.sys_instance = system.System( diff --git a/sushy/tests/unit/resources/registry/test_attribute_registry.py b/sushy/tests/unit/resources/registry/test_attribute_registry.py index 4467f16f..d49eb254 100644 --- a/sushy/tests/unit/resources/registry/test_attribute_registry.py +++ b/sushy/tests/unit/resources/registry/test_attribute_registry.py @@ -23,7 +23,7 @@ from sushy.tests.unit import base class AttributeRegistryTestCase(base.TestCase): def setUp(self): - super(AttributeRegistryTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'bios_attribute_registry.json') as f: diff --git a/sushy/tests/unit/resources/registry/test_message_registry.py b/sushy/tests/unit/resources/registry/test_message_registry.py index 94ebcd67..8aba4358 100644 --- a/sushy/tests/unit/resources/registry/test_message_registry.py +++ b/sushy/tests/unit/resources/registry/test_message_registry.py @@ -28,7 +28,7 @@ from sushy.tests.unit import base class MessageRegistryTestCase(base.TestCase): def setUp(self): - super(MessageRegistryTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/message_registry.json') as f: self.json_doc = json.load(f) diff --git a/sushy/tests/unit/resources/registry/test_message_registry_file.py b/sushy/tests/unit/resources/registry/test_message_registry_file.py index a9b93fd5..db3cbb06 100644 --- a/sushy/tests/unit/resources/registry/test_message_registry_file.py +++ b/sushy/tests/unit/resources/registry/test_message_registry_file.py @@ -24,7 +24,7 @@ from sushy.tests.unit import base class MessageRegistryFileTestCase(base.TestCase): def setUp(self): - super(MessageRegistryFileTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'message_registry_file.json') as f: @@ -276,7 +276,7 @@ class MessageRegistryFileTestCase(base.TestCase): class BiosRegistryTestCase(base.TestCase): def setUp(self): - super(BiosRegistryTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'bios_attribute_registry_file.json') as f: @@ -314,7 +314,7 @@ class BiosRegistryTestCase(base.TestCase): class MessageRegistryFileCollectionTestCase(base.TestCase): def setUp(self): - super(MessageRegistryFileCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'message_registry_file_collection.json') as f: diff --git a/sushy/tests/unit/resources/sessionservice/test_session.py b/sushy/tests/unit/resources/sessionservice/test_session.py index e498e863..94d1b8ca 100644 --- a/sushy/tests/unit/resources/sessionservice/test_session.py +++ b/sushy/tests/unit/resources/sessionservice/test_session.py @@ -24,7 +24,7 @@ from sushy.tests.unit import base class SessionTestCase(base.TestCase): def setUp(self): - super(SessionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.auth = mock.Mock() with open('sushy/tests/unit/json_samples/session.json') as f: @@ -64,7 +64,7 @@ class SessionTestCase(base.TestCase): class SessionCollectionTestCase(base.TestCase): def setUp(self): - super(SessionCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'session_collection.json') as f: diff --git a/sushy/tests/unit/resources/sessionservice/test_sessionservice.py b/sushy/tests/unit/resources/sessionservice/test_sessionservice.py index 7b1483db..0f108287 100644 --- a/sushy/tests/unit/resources/sessionservice/test_sessionservice.py +++ b/sushy/tests/unit/resources/sessionservice/test_sessionservice.py @@ -26,7 +26,7 @@ from sushy.tests.unit import base class SessionServiceTestCase(base.TestCase): def setUp(self): - super(SessionServiceTestCase, self).setUp() + super().setUp() self.conn = mock.MagicMock() with open('sushy/tests/unit/json_samples/session_service.json') as f: self.json_doc = json.load(f) diff --git a/sushy/tests/unit/resources/system/network/test_adapter.py b/sushy/tests/unit/resources/system/network/test_adapter.py index c86d7d80..bcd304ba 100644 --- a/sushy/tests/unit/resources/system/network/test_adapter.py +++ b/sushy/tests/unit/resources/system/network/test_adapter.py @@ -25,7 +25,7 @@ from sushy.tests.unit import base class NetworkAdapterTestCase(base.TestCase): def setUp(self): - super(NetworkAdapterTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/network_adapter.json') as f: self.json_doc = json.load(f) @@ -151,7 +151,7 @@ class NetworkAdapterTestCase(base.TestCase): class NetworkAdapterCollectionTestCase(base.TestCase): def setUp(self): - super(NetworkAdapterCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'network_adapter_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/network/test_device_function.py b/sushy/tests/unit/resources/system/network/test_device_function.py index a5295b07..f3445d03 100644 --- a/sushy/tests/unit/resources/system/network/test_device_function.py +++ b/sushy/tests/unit/resources/system/network/test_device_function.py @@ -22,7 +22,7 @@ from sushy.tests.unit import base class NetworkDeviceFunctionTestCase(base.TestCase): def setUp(self): - super(NetworkDeviceFunctionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'network_device_function.json') as f: @@ -101,7 +101,7 @@ class NetworkDeviceFunctionTestCase(base.TestCase): class NetworkDeviceFunctionCollectionTestCase(base.TestCase): def setUp(self): - super(NetworkDeviceFunctionCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'network_device_function_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/network/test_port.py b/sushy/tests/unit/resources/system/network/test_port.py index 43dc7c61..6b00c816 100644 --- a/sushy/tests/unit/resources/system/network/test_port.py +++ b/sushy/tests/unit/resources/system/network/test_port.py @@ -22,7 +22,7 @@ from sushy.tests.unit import base class NetworkPortTestCase(base.TestCase): def setUp(self): - super(NetworkPortTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/network_port.json') as f: self.json_doc = json.load(f) @@ -56,7 +56,7 @@ class NetworkPortTestCase(base.TestCase): class NetworkPortCollectionTestCase(base.TestCase): def setUp(self): - super(NetworkPortCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'network_port_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/storage/test_controller.py b/sushy/tests/unit/resources/system/storage/test_controller.py index a51fe2f5..bb857362 100644 --- a/sushy/tests/unit/resources/system/storage/test_controller.py +++ b/sushy/tests/unit/resources/system/storage/test_controller.py @@ -23,7 +23,7 @@ from sushy.tests.unit import base class ControllerTestCase(base.TestCase): def setUp(self): - super(ControllerTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'storage_controller.json') as f: @@ -92,7 +92,7 @@ class ControllerTestCase(base.TestCase): class ControllerCollectionTestCase(base.TestCase): def setUp(self): - super(ControllerCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'storage_controller_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/storage/test_drive.py b/sushy/tests/unit/resources/system/storage/test_drive.py index 03c3de5d..c435395f 100644 --- a/sushy/tests/unit/resources/system/storage/test_drive.py +++ b/sushy/tests/unit/resources/system/storage/test_drive.py @@ -23,7 +23,7 @@ from sushy.tests.unit import base class DriveTestCase(base.TestCase): def setUp(self): - super(DriveTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/drive.json') as f: self.json_doc = json.load(f) diff --git a/sushy/tests/unit/resources/system/storage/test_storage.py b/sushy/tests/unit/resources/system/storage/test_storage.py index 1420fa18..9eeb8552 100644 --- a/sushy/tests/unit/resources/system/storage/test_storage.py +++ b/sushy/tests/unit/resources/system/storage/test_storage.py @@ -40,7 +40,7 @@ STORAGE_VOLUME_FILE_NAMES = [ class StorageTestCase(base.TestCase): def setUp(self): - super(StorageTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/storage.json') as f: self.json_doc = json.load(f) @@ -254,7 +254,7 @@ class StorageTestCase(base.TestCase): class StorageCollectionTestCase(base.TestCase): def setUp(self): - super(StorageCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'storage_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/storage/test_volume.py b/sushy/tests/unit/resources/system/storage/test_volume.py index dda38ee0..bc7b7d37 100644 --- a/sushy/tests/unit/resources/system/storage/test_volume.py +++ b/sushy/tests/unit/resources/system/storage/test_volume.py @@ -27,7 +27,7 @@ from sushy.tests.unit import base class VolumeTestCase(base.TestCase): def setUp(self): - super(VolumeTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/volume.json') as f: self.json_doc = json.load(f) @@ -189,7 +189,7 @@ class VolumeTestCase(base.TestCase): class VolumeCollectionTestCase(base.TestCase): def setUp(self): - super(VolumeCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'volume_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/test_bios.py b/sushy/tests/unit/resources/system/test_bios.py index 894bc4b6..8128f4d1 100644 --- a/sushy/tests/unit/resources/system/test_bios.py +++ b/sushy/tests/unit/resources/system/test_bios.py @@ -31,7 +31,7 @@ from sushy.tests.unit import base class BiosTestCase(base.TestCase): def setUp(self): - super(BiosTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/bios.json') as f: self.bios_json = json.load(f) @@ -365,7 +365,7 @@ class BiosTestCase(base.TestCase): class BiosZTTestCase(base.TestCase): def setUp(self): - super(BiosZTTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/bios_zt.json') as f: self.bios_json = json.load(f) diff --git a/sushy/tests/unit/resources/system/test_ethernet_interfaces.py b/sushy/tests/unit/resources/system/test_ethernet_interfaces.py index 58aa7497..1d60debf 100644 --- a/sushy/tests/unit/resources/system/test_ethernet_interfaces.py +++ b/sushy/tests/unit/resources/system/test_ethernet_interfaces.py @@ -22,7 +22,7 @@ from sushy.tests.unit import base class EthernetInterfaceTestCase(base.TestCase): def setUp(self): - super(EthernetInterfaceTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'ethernet_interfaces.json') as f: @@ -52,7 +52,7 @@ class EthernetInterfaceTestCase(base.TestCase): class EthernetInterfaceCollectionTestCase(base.TestCase): def setUp(self): - super(EthernetInterfaceCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'ethernet_interfaces_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/test_port.py b/sushy/tests/unit/resources/system/test_port.py index 900af6b4..b2548516 100644 --- a/sushy/tests/unit/resources/system/test_port.py +++ b/sushy/tests/unit/resources/system/test_port.py @@ -22,7 +22,7 @@ from sushy.tests.unit import base class PortTestCase(base.TestCase): def setUp(self): - super(PortTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/port.json') as f: self.json_doc = json.load(f) @@ -57,7 +57,7 @@ class PortTestCase(base.TestCase): class PortCollectionTestCase(base.TestCase): def setUp(self): - super(PortCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'port_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/test_processor.py b/sushy/tests/unit/resources/system/test_processor.py index a6bf9b2d..d3fce43a 100644 --- a/sushy/tests/unit/resources/system/test_processor.py +++ b/sushy/tests/unit/resources/system/test_processor.py @@ -26,7 +26,7 @@ from sushy.tests.unit import base class ProcessorTestCase(base.TestCase): def setUp(self): - super(ProcessorTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/processor.json') as f: self.json_doc = json.load(f) @@ -102,7 +102,7 @@ class ProcessorTestCase(base.TestCase): class ProcessorCollectionTestCase(base.TestCase): def setUp(self): - super(ProcessorCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'processor_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/test_secure_boot.py b/sushy/tests/unit/resources/system/test_secure_boot.py index 978f74ed..3c12f36b 100644 --- a/sushy/tests/unit/resources/system/test_secure_boot.py +++ b/sushy/tests/unit/resources/system/test_secure_boot.py @@ -23,7 +23,7 @@ from sushy.tests.unit import base class SecureBootTestCase(base.TestCase): def setUp(self): - super(SecureBootTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/secure_boot.json') as f: self.secure_boot_json = json.load(f) diff --git a/sushy/tests/unit/resources/system/test_secure_boot_database.py b/sushy/tests/unit/resources/system/test_secure_boot_database.py index 48530f74..43bbdb67 100644 --- a/sushy/tests/unit/resources/system/test_secure_boot_database.py +++ b/sushy/tests/unit/resources/system/test_secure_boot_database.py @@ -22,7 +22,7 @@ from sushy.tests.unit import base class SecureBootDatabaseTestCase(base.TestCase): def setUp(self): - super(SecureBootDatabaseTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'secure_boot_database.json') as f: @@ -86,7 +86,7 @@ class SecureBootDatabaseTestCase(base.TestCase): class SecureBootDatabaseCollectionTestCase(base.TestCase): def setUp(self): - super(SecureBootDatabaseCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'secure_boot_database_collection.json') as f: @@ -131,7 +131,7 @@ class SecureBootDatabaseCollectionTestCase(base.TestCase): calls = [ mock.call(self.collection._conn, '/redfish/v1/Systems/437XR1138R2/SecureBoot' - '/SecureBootDatabases/%s' % member, + f'/SecureBootDatabases/{member}', redfish_version=self.collection.redfish_version, registries=None, root=self.collection.root) diff --git a/sushy/tests/unit/resources/system/test_simple_storage.py b/sushy/tests/unit/resources/system/test_simple_storage.py index aeb6f941..0845c1ec 100644 --- a/sushy/tests/unit/resources/system/test_simple_storage.py +++ b/sushy/tests/unit/resources/system/test_simple_storage.py @@ -22,7 +22,7 @@ from sushy.tests.unit import base class SimpleStorageTestCase(base.TestCase): def setUp(self): - super(SimpleStorageTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'simple_storage.json') as f: @@ -54,7 +54,7 @@ class SimpleStorageTestCase(base.TestCase): class SimpleStorageCollectionTestCase(base.TestCase): def setUp(self): - super(SimpleStorageCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'simple_storage_collection.json') as f: diff --git a/sushy/tests/unit/resources/system/test_system.py b/sushy/tests/unit/resources/system/test_system.py index 2c3c52b9..63e4ce32 100644 --- a/sushy/tests/unit/resources/system/test_system.py +++ b/sushy/tests/unit/resources/system/test_system.py @@ -36,7 +36,7 @@ from sushy.tests.unit import base class SystemTestCase(base.TestCase): def setUp(self): - super(SystemTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.conn.get.return_value.headers = {'Allow': 'GET,HEAD'} with open('sushy/tests/unit/json_samples/system.json') as f: @@ -339,8 +339,7 @@ class SystemTestCase(base.TestCase): def test_set_system_boot_options_invalid_enabled(self): with self.assertRaisesRegex( exceptions.InvalidParameterValueError, - '"enabled" value.*{0}'.format( - list(sushy.BootSourceOverrideEnabled))): + f'"enabled" value.*{list(sushy.BootSourceOverrideEnabled)}'): self.sys_inst.set_system_boot_options( sushy.BootSource.HDD, @@ -622,8 +621,7 @@ class SystemTestCase(base.TestCase): def test_set_system_boot_source_invalid_enabled(self): with self.assertRaisesRegex( exceptions.InvalidParameterValueError, - '"enabled" value.*{0}'.format( - list(sushy.BootSourceOverrideEnabled))): + f'"enabled" value.*{list(sushy.BootSourceOverrideEnabled)}'): self.sys_inst.set_system_boot_source( sushy.BootSource.HDD, @@ -976,7 +974,7 @@ class SystemTestCase(base.TestCase): class SystemWithVirtualMedia(base.TestCase): def setUp(self): - super(SystemWithVirtualMedia, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'systemv1_20.json') as f: @@ -1028,7 +1026,7 @@ class SystemWithVirtualMedia(base.TestCase): self.assertIsInstance(actual_virtual_media, virtual_media.VirtualMediaCollection) - with open('sushy/tests/unit/json_samples/systemv1_20.json', 'r') as f: + with open('sushy/tests/unit/json_samples/systemv1_20.json') as f: self.conn.get.return_value.json.return_value = json.loads(f.read()) self.sys_inst.invalidate() @@ -1050,7 +1048,7 @@ class SystemWithVirtualMedia(base.TestCase): class SystemCollectionTestCase(base.TestCase): def setUp(self): - super(SystemCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'system_collection.json') as f: diff --git a/sushy/tests/unit/resources/taskservice/test_task.py b/sushy/tests/unit/resources/taskservice/test_task.py index a620e973..5a77df05 100644 --- a/sushy/tests/unit/resources/taskservice/test_task.py +++ b/sushy/tests/unit/resources/taskservice/test_task.py @@ -24,7 +24,7 @@ from sushy.tests.unit import base class TaskTestCase(base.TestCase): def setUp(self): - super(TaskTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/task.json') as f: self.json_doc = json.load(f) @@ -78,7 +78,7 @@ class TaskTestCase(base.TestCase): class TaskCollectionTestCase(base.TestCase): def setUp(self): - super(TaskCollectionTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'task_collection.json') as f: diff --git a/sushy/tests/unit/resources/taskservice/test_taskservice.py b/sushy/tests/unit/resources/taskservice/test_taskservice.py index b9cda72a..cce658b4 100644 --- a/sushy/tests/unit/resources/taskservice/test_taskservice.py +++ b/sushy/tests/unit/resources/taskservice/test_taskservice.py @@ -24,7 +24,7 @@ from sushy.tests.unit import base class TaskServiceTestCase(base.TestCase): def setUp(self): - super(TaskServiceTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/taskservice.json') as f: self.json_doc = json.load(f) diff --git a/sushy/tests/unit/resources/test_base.py b/sushy/tests/unit/resources/test_base.py index a6526cd4..7136506d 100644 --- a/sushy/tests/unit/resources/test_base.py +++ b/sushy/tests/unit/resources/test_base.py @@ -72,7 +72,7 @@ class BaseResource2(resource_base.ResourceBase): class ResourceBaseTestCase(base.TestCase): def setUp(self): - super(ResourceBaseTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.conn.get.return_value.json.return_value = ( copy.deepcopy(BASE_RESOURCE_JSON)) @@ -194,8 +194,8 @@ class TestResource(resource_base.ResourceBase): :param registries: Dict of Redfish Message Registry objects to be used in any resource that needs registries to parse messages. """ - super(TestResource, self).__init__(connector, 'Fakes/%s' % identity, - redfish_version, registries, root) + super().__init__(connector, f'Fakes/{identity}', + redfish_version, registries, root) self.identity = identity def _parse_attributes(self, json_doc): @@ -219,14 +219,14 @@ class TestResourceCollection(resource_base.ResourceCollectionBase): :param registries: Dict of Redfish Message Registry objects to be used in any resource that needs registries to parse messages. """ - super(TestResourceCollection, self).__init__( + super().__init__( connector, 'Fakes', redfish_version, registries, root) class ResourceCollectionBaseTestCase(base.TestCase): def setUp(self): - super(ResourceCollectionBaseTestCase, self).setUp() + super().setUp() self.conn = mock.MagicMock() self.test_resource_collection = TestResourceCollection( self.conn, redfish_version='1.0.x', registries=None) @@ -389,7 +389,7 @@ class ComplexResource(resource_base.ResourceBase): class FieldTestCase(base.TestCase): def setUp(self): - super(FieldTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.json = copy.deepcopy(TEST_JSON) self.conn.get.return_value.json.return_value = self.json @@ -493,7 +493,7 @@ class PartialKeyResource(resource_base.ResourceBase): class FieldPartialKeyTestCase(base.TestCase): def setUp(self): - super(FieldPartialKeyTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.json = copy.deepcopy(TEST_JSON) self.conn.get.return_value.json.return_value = self.json diff --git a/sushy/tests/unit/resources/test_settings.py b/sushy/tests/unit/resources/test_settings.py index 32628ad5..ad31566f 100644 --- a/sushy/tests/unit/resources/test_settings.py +++ b/sushy/tests/unit/resources/test_settings.py @@ -25,7 +25,7 @@ from sushy.tests.unit import base class SettingsFieldTestCase(base.TestCase): def setUp(self): - super(SettingsFieldTestCase, self).setUp() + super().setUp() with open('sushy/tests/unit/json_samples/settings.json') as f: self.json = json.load(f) diff --git a/sushy/tests/unit/resources/updateservice/test_softwareinventory.py b/sushy/tests/unit/resources/updateservice/test_softwareinventory.py index bbc99cb3..7abdb297 100644 --- a/sushy/tests/unit/resources/updateservice/test_softwareinventory.py +++ b/sushy/tests/unit/resources/updateservice/test_softwareinventory.py @@ -23,7 +23,7 @@ from sushy.tests.unit import base class SoftwareInventoryTestCase(base.TestCase): def setUp(self): - super(SoftwareInventoryTestCase, self).setUp() + super().setUp() conn = mock.Mock() with open( 'sushy/tests/unit/json_samples/softwareinventory.json') as f: @@ -76,7 +76,7 @@ class SoftwareInventoryTestCase(base.TestCase): class SoftwareInventoryCollectionTestCase(base.TestCase): def setUp(self): - super(SoftwareInventoryCollectionTestCase, self).setUp() + super().setUp() conn = mock.Mock() with open('sushy/tests/unit/json_samples/' 'firmwareinventory_collection.json') as f: diff --git a/sushy/tests/unit/resources/updateservice/test_updateservice.py b/sushy/tests/unit/resources/updateservice/test_updateservice.py index ce3b9f6a..1d4ffe32 100644 --- a/sushy/tests/unit/resources/updateservice/test_updateservice.py +++ b/sushy/tests/unit/resources/updateservice/test_updateservice.py @@ -26,7 +26,7 @@ from sushy.tests.unit import base class UpdateServiceTestCase(base.TestCase): def setUp(self): - super(UpdateServiceTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/updateservice.json') as f: self.json_doc = json.load(f) @@ -194,7 +194,7 @@ class UpdateServiceTestCase(base.TestCase): class UpdateServiceNoInvTestCase(base.TestCase): def setUp(self): - super(UpdateServiceNoInvTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() no_inv_json = 'sushy/tests/unit/json_samples/updateservice_no_inv.json' with open(no_inv_json) as f: diff --git a/sushy/tests/unit/test_auth.py b/sushy/tests/unit/test_auth.py index 126d0baa..811ce5c3 100644 --- a/sushy/tests/unit/test_auth.py +++ b/sushy/tests/unit/test_auth.py @@ -29,7 +29,7 @@ class BasicAuthTestCase(base.TestCase): @mock.patch.object(main, 'Sushy', autospec=True) @mock.patch.object(connector, 'Connector', autospec=True) def setUp(self, mock_connector, mock_root): - super(BasicAuthTestCase, self).setUp() + super().setUp() self.username = 'TestUsername' self.password = 'TestP@$$W0RD' self.base_auth = auth.BasicAuth(self.username, @@ -78,7 +78,7 @@ class SessionAuthTestCase(base.TestCase): @mock.patch.object(main, 'Sushy', autospec=True) @mock.patch.object(connector, 'Connector', autospec=True) def setUp(self, mock_connector, mock_root): - super(SessionAuthTestCase, self).setUp() + super().setUp() self.username = 'TestUsername' self.password = 'TestP@$$W0RD' self.sess_key = 'TestingKey' @@ -217,7 +217,7 @@ class SessionOrBasicAuthTestCase(base.TestCase): @mock.patch.object(main, 'Sushy', autospec=True) @mock.patch.object(connector, 'Connector', autospec=True) def setUp(self, mock_connector, mock_root): - super(SessionOrBasicAuthTestCase, self).setUp() + super().setUp() self.username = 'TestUsername' self.password = 'TestP@$$W0RD' self.sess_key = 'TestingKey' diff --git a/sushy/tests/unit/test_connector.py b/sushy/tests/unit/test_connector.py index bb0de36b..d527fae7 100644 --- a/sushy/tests/unit/test_connector.py +++ b/sushy/tests/unit/test_connector.py @@ -30,7 +30,7 @@ class ConnectorMethodsTestCase(base.TestCase): @mock.patch.object(sushy_auth, 'SessionOrBasicAuth', autospec=True) def setUp(self, mock_auth): mock_auth.get_session_key.return_value = None - super(ConnectorMethodsTestCase, self).setUp() + super().setUp() self.conn = connector.Connector( 'http://foo.bar:1234', verify=True) self.conn._auth = mock_auth @@ -162,7 +162,7 @@ class ConnectorOpTestCase(base.TestCase): mock_auth.get_session_key.return_value = None mock_auth._session_key = None self.auth = mock_auth - super(ConnectorOpTestCase, self).setUp() + super().setUp() self.conn = connector.Connector( 'http://foo.bar:1234', verify=True, server_side_retries=10, server_side_retries_delay=3) @@ -666,8 +666,8 @@ class ConnectorOpTestCase(base.TestCase): 'HTTP GET of SessionService failed %s, ' 'this is expected prior to authentication', 'HTTP GET ' 'http://redfish/v1/SessionService returned code ' - '%s. unknown error Extended information: ' - 'None' % http_client.FORBIDDEN) + f'{http_client.FORBIDDEN!s}. unknown error Extended ' + 'information: None') self.assertEqual(http_client.FORBIDDEN, exc.status_code) def test_blocking_no_location_header(self): diff --git a/sushy/tests/unit/test_main.py b/sushy/tests/unit/test_main.py index a632262d..f1731e75 100644 --- a/sushy/tests/unit/test_main.py +++ b/sushy/tests/unit/test_main.py @@ -40,7 +40,7 @@ class MainTestCase(base.TestCase): @mock.patch.object(connector, 'Connector', autospec=True) @mock.patch.object(sessionservice, 'SessionService', autospec=True) def setUp(self, mock_session_service, mock_connector, mock_auth): - super(MainTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.sess_serv = mock.Mock() self.sess_serv.create_session.return_value = (None, None) @@ -561,7 +561,7 @@ class MainTestCase(base.TestCase): class BareMinimumMainTestCase(base.TestCase): def setUp(self): - super(BareMinimumMainTestCase, self).setUp() + super().setUp() self.conn = mock.MagicMock() with open('sushy/tests/unit/json_samples/' 'bare_minimum_root.json') as f: diff --git a/sushy/tests/unit/test_taskmonitor.py b/sushy/tests/unit/test_taskmonitor.py index 8ae2c16c..400b029b 100644 --- a/sushy/tests/unit/test_taskmonitor.py +++ b/sushy/tests/unit/test_taskmonitor.py @@ -27,7 +27,7 @@ from sushy.tests.unit import base class TaskMonitorTestCase(base.TestCase): def setUp(self): - super(TaskMonitorTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() with open('sushy/tests/unit/json_samples/task.json') as f: diff --git a/sushy/tests/unit/test_utils.py b/sushy/tests/unit/test_utils.py index 04178d2c..3d77ff29 100644 --- a/sushy/tests/unit/test_utils.py +++ b/sushy/tests/unit/test_utils.py @@ -52,7 +52,7 @@ class UtilsTestCase(base.TestCase): self.assertEqual(True, utils.bool_or_none(True)) def setUp(self): - super(UtilsTestCase, self).setUp() + super().setUp() self.conn = mock.MagicMock() with open('sushy/tests/unit/json_samples/system.json') as f: system_json = json.load(f) @@ -178,7 +178,7 @@ class BaseResource(resource_base.ResourceBase): class CacheTestCase(base.TestCase): def setUp(self): - super(CacheTestCase, self).setUp() + super().setUp() self.conn = mock.Mock() self.res = BaseResource(connector=self.conn, path='/Foo', redfish_version='1.0.2') diff --git a/sushy/utils.py b/sushy/utils.py index f068fb9a..320c4c33 100644 --- a/sushy/utils.py +++ b/sushy/utils.py @@ -118,7 +118,7 @@ def get_sub_resource_path_by(resource, subresource_name, is_collection=False): except (TypeError, KeyError): attribute = '/'.join(subresource_name) if is_collection: - attribute += '[%s]' % len(elements) + attribute += f'[{len(elements)}]' attribute += '/@odata.id' raise exceptions.MissingAttributeError( attribute=attribute, resource=resource.path)