From 54a677e0ce6fd2b56a039b79fc4a723e0815c060 Mon Sep 17 00:00:00 2001 From: iuvbio Date: Sat, 8 Jun 2019 14:30:53 +0200 Subject: [PATCH] add additional tests for exception handling --- pandas_ods_reader/tests/test_read_ods.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pandas_ods_reader/tests/test_read_ods.py b/pandas_ods_reader/tests/test_read_ods.py index 1e59e85..dd4de2e 100644 --- a/pandas_ods_reader/tests/test_read_ods.py +++ b/pandas_ods_reader/tests/test_read_ods.py @@ -1,6 +1,7 @@ import os import pandas as pd +import pytest from pandas_ods_reader import read_ods @@ -58,3 +59,16 @@ class TestOdsReader(object): assert isinstance(df, pd.DataFrame) assert len(df) == 10 assert (len(df.columns) == 5) + + def test_wrong_id_type(self): + path = os.path.join(rsc, header_file) + with pytest.raises(ValueError) as e_info: + read_ods(path, 1.0) + assert e_info.match("Sheet id has to be either `str` or `int`") + + def test_non_existent_sheet(self): + path = os.path.join(rsc, header_file) + sheet_name = "No_Sheet" + with pytest.raises(ValueError) as e_info: + read_ods(path, sheet_name) + assert e_info.match(f"There is no sheet named {sheet_name}")