From f1c1c47502e865767b8b9515b4d47fbd06a01534 Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Fri, 12 Apr 2024 12:45:44 +0200 Subject: [PATCH] Fix memory being reported without units in GUI --- src/ert/gui/model/snapshot.py | 6 +++--- tests/unit_tests/gui/simulation/test_run_dialog.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ert/gui/model/snapshot.py b/src/ert/gui/model/snapshot.py index 962e141be39..36bf4f8888c 100644 --- a/src/ert/gui/model/snapshot.py +++ b/src/ert/gui/model/snapshot.py @@ -433,10 +433,10 @@ def _job_data(self, index: QModelIndex, node: Node, role: int): if role == Qt.DisplayRole: _, data_name = COLUMNS[NodeType.REAL][index.column()] if data_name in [ids.CURRENT_MEMORY_USAGE, ids.MAX_MEMORY_USAGE]: - data = node.data.get(ids.DATA) - _bytes = data.get(data_name) if data else None + data = node.data + _bytes: Optional[str] = data.get(data_name) if data else None if _bytes: - return byte_with_unit(_bytes) + return byte_with_unit(float(_bytes)) if data_name in [ids.STDOUT, ids.STDERR]: return "OPEN" if node.data.get(data_name) else QVariant() diff --git a/tests/unit_tests/gui/simulation/test_run_dialog.py b/tests/unit_tests/gui/simulation/test_run_dialog.py index a8e171734cc..68a1262ff9e 100644 --- a/tests/unit_tests/gui/simulation/test_run_dialog.py +++ b/tests/unit_tests/gui/simulation/test_run_dialog.py @@ -494,7 +494,7 @@ def test_run_dialog_memory_usage_showing( current_memory_value = widget._job_model.data( current_memory_column_proxy_index, Qt.DisplayRole ) - assert current_memory_value == "50000" + assert current_memory_value == "50.00 kB" max_memory_column_proxy_index = widget._job_model.index( job_number, max_memory_column_index @@ -502,7 +502,7 @@ def test_run_dialog_memory_usage_showing( max_memory_value = widget._job_model.data( max_memory_column_proxy_index, Qt.DisplayRole ) - assert max_memory_value == "60000" + assert max_memory_value == "60.00 kB" @pytest.mark.usefixtures("use_tmpdir", "set_site_config", "using_scheduler")