Skip to content

Commit 084b460

Browse files
committed
improved a few error messages and fixed tests which checked them
1 parent 9cf4d48 commit 084b460

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

larray/inout/xw_reporting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ def set_item_default_size(self, kind, width=None, height=None):
132132
raise ValueError("No value provided for both 'width' and 'heigth'. "
133133
"Please provide one for at least 'width' or 'heigth'")
134134
if kind not in self.default_items_size:
135-
raise ValueError("Type item {} is not registered. Please choose in "
136-
"list {}".format(kind, self.default_items_size.keys()))
135+
raise ValueError("Item type {} is not registered. Please choose in "
136+
"list {}".format(kind, list(self.default_items_size.keys())))
137137
if width is None:
138138
width = self.default_items_size[kind].width
139139
if height is None:

larray/tests/test_excel.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ def test_excel_report_setting_template():
278278
# test setting template dir
279279
# 1) wrong template dir
280280
wrong_template_dir = r"C:\Wrong\Directory\Path"
281-
msg = "Template directory {} could not been found".format(wrong_template_dir)
282-
with pytest.raises(ValueError, message=msg):
281+
msg = "The directory {} could not be found".format(wrong_template_dir)
282+
with pytest.raises(ValueError, match=re.escape(msg)):
283283
excel_report.template_dir = wrong_template_dir
284284
# 2) correct path
285285
excel_report.template_dir = EXAMPLE_EXCEL_TEMPLATES_DIR
@@ -288,8 +288,8 @@ def test_excel_report_setting_template():
288288
# test setting template file
289289
# 1) wrong extension
290290
template_file = 'wrong_extension.txt'
291-
msg = "Extension for the template file must be '.crtx' instead of .txt"
292-
with pytest.raises(ValueError, message=msg):
291+
msg = "Extension for the excel template file must be '.crtx' instead of .txt"
292+
with pytest.raises(ValueError, match=re.escape(msg)):
293293
excel_report.template = template_file
294294
# 2) add .crtx extension if no extension
295295
template_name = 'Line'
@@ -365,11 +365,11 @@ def test_excel_report_arrays():
365365

366366
# test setting default size
367367
# 1) pass a not registered kind of item
368-
type_item = 'unknown_item'
369-
msg = "Type item {} is not registered. Please choose in " \
370-
"list ['title', 'graph']".format(type_item)
371-
with pytest.raises(ValueError, message=msg):
372-
sheet_graphs.set_item_default_size(type_item, width, height)
368+
item_type = 'unknown_item'
369+
msg = "Item type {} is not registered. Please choose in " \
370+
"list ['title', 'graph']".format(item_type)
371+
with pytest.raises(ValueError, match=re.escape(msg)):
372+
sheet_graphs.set_item_default_size(item_type, width, height)
373373
# 2) update default size for graphs
374374
sheet_graphs.set_item_default_size('graph', width, height)
375375
sheet_graphs.add_title('Using Defined Sizes For All Graphs')

larray/util/misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,4 +1028,4 @@ def _positive_integer(value):
10281028

10291029
def _validate_dir(directory):
10301030
if not os.path.isdir(directory):
1031-
raise ValueError("The directory {} could not been found".format(directory))
1031+
raise ValueError("The directory {} could not be found".format(directory))

0 commit comments

Comments
 (0)