if sheet does not exist, raise KeyError instead of ValueError
This commit is contained in:
parent
35724dde06
commit
e1c602d01a
|
|
@ -14,7 +14,7 @@ def load_ods(doc, sheet_id, headers=True, columns=None):
|
|||
if isinstance(sheet_id, str):
|
||||
sheets = [sheet.name for sheet in doc.sheets]
|
||||
if sheet_id not in sheets:
|
||||
raise ValueError("There is no sheet named {}".format(sheet_id))
|
||||
raise KeyError("There is no sheet named {}".format(sheet_id))
|
||||
sheet_id = sheets.index(sheet_id) + 1
|
||||
sheet = doc.sheets[sheet_id - 1]
|
||||
df_dict = OrderedDict()
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ class TestOdsReader:
|
|||
path = rsc / header_file
|
||||
sheet_name = "No_Sheet"
|
||||
|
||||
with pytest.raises(ValueError) as e_info:
|
||||
with pytest.raises(KeyError) as e_info:
|
||||
read_ods(path, sheet_name)
|
||||
assert e_info.match(f"There is no sheet named {sheet_name}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue