Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove modbus pragma no cover and solve nan #99221

Merged
merged 7 commits into from
Sep 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review.
janiversen committed Sep 12, 2023
commit ab8491fb6f1cf836944b8f614d588083472c681c
2 changes: 1 addition & 1 deletion homeassistant/components/modbus/base_platform.py
Original file line number Diff line number Diff line change
@@ -239,7 +239,7 @@ def unpack_structure_result(self, registers: list[int]) -> str | None:
v_result.append("0")
elif v_temp != v_temp: # noqa: PLR0124
# NaN float detection replace with None
v_result.append("nan")
v_result.append("0")
else:
v_result.append(f"{float(v_temp):.{self._precision}f}")
return ",".join(map(str, v_result))

Unchanged files with check annotations Beta

)
async def test_struct_sensor(hass: HomeAssistant, mock_do_cycle, expected) -> None:
"""Run test for sensor struct."""
assert hass.states.get(ENTITY_ID).state == expected

Check failure on line 1121 in tests/components/modbus/test_sensor.py

GitHub Actions / Run tests Python 3.11 (5)

test_struct_sensor[config_addon0-register_words0-nan,10.60,0.00,10.57-do_config0] AssertionError: assert '0,10.60,0.00,10.57' == 'nan,10.60,0.00,10.57' - nan,10.60,0.00,10.57 ? ^^^ + 0,10.60,0.00,10.57 ? ^
@pytest.mark.parametrize(