Commit e682d49e authored by nimrod's avatar nimrod
Browse files

Handle missing units without failure.

Still need to deal with multiple perf data in a single line (not sure if
it's technically correct at all).
parent c077d69e
Loading
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -50,12 +50,12 @@ def parse_perf_data(line): # noqa: MC0001
        for i in range(len(value) - 1, 0, -1):
            if value[i].isdigit():
                break
        value, unit = (
        pd["value"], pd["unit"] = (
            float(value[: i + 1]),
            value[i + 1 :],  # noqa: E203
        )
    pd["value"] = value
    pd["unit"] = unit
    else:
        pd["value"] = float(value)

    # Get the remaining fields, if available.
    try:
+1 −2
Original line number Diff line number Diff line
@@ -119,8 +119,7 @@ def test_data_perf(line):
    assert isinstance(pd.name, str)
    assert len(pd.name) > 0
    assert isinstance(pd.value, float)
    assert isinstance(pd.unit, str)
    assert len(pd.unit) > 0
    assert isinstance(pd.unit, (str, type(None)))
    assert isinstance(pd.warning, (float, type(None)))
    assert isinstance(pd.critical, (float, type(None)))
    assert isinstance(pd.min, (float, type(None)))