Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
Pipeline #1997 passed
...@@ -50,12 +50,12 @@ def parse_perf_data(line): # noqa: MC0001 ...@@ -50,12 +50,12 @@ def parse_perf_data(line): # noqa: MC0001
for i in range(len(value) - 1, 0, -1): for i in range(len(value) - 1, 0, -1):
if value[i].isdigit(): if value[i].isdigit():
break break
value, unit = ( pd["value"], pd["unit"] = (
float(value[: i + 1]), float(value[: i + 1]),
value[i + 1 :], # noqa: E203 value[i + 1 :], # noqa: E203
) )
pd["value"] = value else:
pd["unit"] = unit pd["value"] = float(value)
# Get the remaining fields, if available. # Get the remaining fields, if available.
try: try:
......
...@@ -119,8 +119,7 @@ def test_data_perf(line): ...@@ -119,8 +119,7 @@ def test_data_perf(line):
assert isinstance(pd.name, str) assert isinstance(pd.name, str)
assert len(pd.name) > 0 assert len(pd.name) > 0
assert isinstance(pd.value, float) assert isinstance(pd.value, float)
assert isinstance(pd.unit, str) assert isinstance(pd.unit, (str, type(None)))
assert len(pd.unit) > 0
assert isinstance(pd.warning, (float, type(None))) assert isinstance(pd.warning, (float, type(None)))
assert isinstance(pd.critical, (float, type(None))) assert isinstance(pd.critical, (float, type(None)))
assert isinstance(pd.min, (float, type(None))) assert isinstance(pd.min, (float, type(None)))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment