From 8df6bd33b9823eb061edea02af5664ce24e58988 Mon Sep 17 00:00:00 2001 From: Moritz Kirmse Date: Fri, 31 Jan 2025 12:59:32 +0100 Subject: [PATCH] also parse tabs to spaces for pretty print --- geonetwork/gn_api.py | 2 +- tests/test_gn_api.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/geonetwork/gn_api.py b/geonetwork/gn_api.py index 411fd8c..d2f53d1 100644 --- a/geonetwork/gn_api.py +++ b/geonetwork/gn_api.py @@ -93,7 +93,7 @@ def put_record_zip(self, zipdata: IO[bytes], overwrite: bool = True) -> Any: clean_error_stack = [ { **err, - "stack": err["stack"].split("\n") + "stack": [t.replace("\t", " ") for t in err["stack"].split("\n")] } for err in results["errors"] ] diff --git a/tests/test_gn_api.py b/tests/test_gn_api.py index d877d0e..0c82f6c 100644 --- a/tests/test_gn_api.py +++ b/tests/test_gn_api.py @@ -115,7 +115,7 @@ def record_callback(request, context): return { "errors": [ {"message": "err1", "stack": "line1\nline2"}, - {"message": "err2", "stack": "e2/line1\ne2/line2"}, + {"message": "err2", "stack": "e2/line1\n\tat e2/line2"}, ] } m.post('http://geonetwork/api/records', json=record_callback) @@ -125,5 +125,5 @@ def record_callback(request, context): assert err.value.args[0]["code"] == 404 assert err.value.args[0]["details"] == [ {"message": "err1", "stack": ["line1", "line2"]}, - {"message": "err2", "stack": ["e2/line1", "e2/line2"]}, + {"message": "err2", "stack": ["e2/line1", " at e2/line2"]}, ]