Skip to content

Commit

Permalink
Make syntax compatible with python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
aieri committed Dec 11, 2024
1 parent 2910952 commit 2a83587
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ max-complexity = 10

[tool.black]
line-length = 99
target-version = ["py38", "py310"]
exclude = '''
/(
| .eggs
Expand Down
67 changes: 29 additions & 38 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 2a83587

Please sign in to comment.