diff --git a/pyproject.toml b/pyproject.toml index 6e6e3ea0..017feaef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,6 +10,7 @@ max-complexity = 10 [tool.black] line-length = 99 +target-version = ["py38", "py310"] exclude = ''' /( | .eggs diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index b82c9655..326cc68d 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -170,19 +170,16 @@ def test_install_or_upgrade( mock_exporters, mock_exporter_install_returns, ) -> None: - with ( - mock.patch( - "charm.HardwareObserverCharm.exporters", - new_callable=mock.PropertyMock( - return_value=mock_exporters, - ), - ) as mock_exporters, - mock.patch( - "charm.HardwareObserverCharm.stored_tools", - new_callable=mock.PropertyMock( - return_value=stored_tools, - ), - ) as mock_stored_tools, # noqa: F841 + with mock.patch( + "charm.HardwareObserverCharm.exporters", + new_callable=mock.PropertyMock( + return_value=mock_exporters, + ), + ) as mock_exporters, mock.patch( + "charm.HardwareObserverCharm.stored_tools", + new_callable=mock.PropertyMock( + return_value=stored_tools, + ), ): self.harness.begin() self.harness.charm.hw_tool_helper = mock.MagicMock() @@ -218,20 +215,17 @@ def test_install_or_upgrade( def test_remove(self): mock_exporters = {mock.MagicMock(), mock.MagicMock()} mock_stored_tools = {HWTool.IPMI_SENSOR, HWTool.IPMI_SEL, HWTool.SMARTCTL_EXPORTER} - with ( - mock.patch( - "charm.HardwareObserverCharm.exporters", - new_callable=mock.PropertyMock( - return_value=mock_exporters, - ), - ) as mock_exporters, - mock.patch( - "charm.HardwareObserverCharm.stored_tools", - new_callable=mock.PropertyMock( - return_value=mock_stored_tools, - ), - ) as mock_stored_tools, - ): + with mock.patch( + "charm.HardwareObserverCharm.exporters", + new_callable=mock.PropertyMock( + return_value=mock_exporters, + ), + ) as mock_exporters, mock.patch( + "charm.HardwareObserverCharm.stored_tools", + new_callable=mock.PropertyMock( + return_value=mock_stored_tools, + ), + ) as mock_stored_tools: self.harness.begin() self.harness.charm.hw_tool_helper = mock.MagicMock() @@ -611,18 +605,15 @@ def test_config_changed_update_alert_rules(self): mock_exporters = [mock_exporter] mock_stored_tools = {HWTool.IPMI_SENSOR, HWTool.IPMI_SEL, HWTool.IPMI_DCMI} - with ( - mock.patch( - "charm.HardwareObserverCharm.exporters", - new_callable=mock.PropertyMock( - return_value=mock_exporters, - ), + with mock.patch( + "charm.HardwareObserverCharm.exporters", + new_callable=mock.PropertyMock( + return_value=mock_exporters, ), - mock.patch( - "charm.HardwareObserverCharm.stored_tools", - new_callable=mock.PropertyMock( - return_value=mock_stored_tools, - ), + ), mock.patch( + "charm.HardwareObserverCharm.stored_tools", + new_callable=mock.PropertyMock( + return_value=mock_stored_tools, ), ): rid = self.harness.add_relation("cos-agent", "grafana-agent")