Use existing invalid test file, generalize error message

This commit is contained in:
guerler
2026-04-29 10:43:57 +03:00
parent 3fc96b017b
commit fd3dfa4d4d
3 changed files with 4 additions and 5 deletions
+1 -1
View File
@@ -4652,7 +4652,7 @@ class RelabelFromFileTool(DatabaseOperationTool):
with open(new_labels_path) as fh:
new_labels = fh.readlines(1024 * 1000000)
except UnicodeDecodeError:
raise exceptions.MessageException("Please re-save the file as UTF-8 and try again.")
raise exceptions.MessageException("Please provide the file as valid UTF-8.")
if strict and len(hdca.collection.elements) != len(new_labels):
raise exceptions.MessageException("Relabel mapping file contains incorrect number of identifiers")
if how_type in ["tabular", "tabular_extended"]:
+3 -4
View File
@@ -5540,9 +5540,8 @@ test_data:
@skip_without_tool("__RELABEL_FROM_FILE__")
def test_relabel_from_file_rejects_non_utf8_labels(self, history_id):
# Regression test: a UTF-16 (Windows-saved) labels file used to crash
# produce_outputs with UnicodeDecodeError. It should now fail with a
# clear MessageException instructing the user to re-save as UTF-8.
# Regression test: a non-UTF-8 labels file (for example UTF-16) should
# fail with a clear MessageException rather than crash on decode.
summary = self._run_workflow(
"""
class: GalaxyWorkflow
@@ -5567,7 +5566,7 @@ test_data:
- identifier: B
content: "beta"
relabel_file:
value: relabel_utf16.tabular
value: random-file
type: File
""",
history_id=history_id,
Binary file not shown.