def test_add_invalid_worksheet_class_instance(): class AlternativeWorksheet(object): def __init__(self, parent_workbook, title=None): self.parent_workbook = parent_workbook if not title: title = 'AlternativeSheet' self.title = title wb = Workbook() ws = AlternativeWorksheet(parent_workbook=wb) with pytest.raises(TypeError): wb._add_sheet(worksheet=ws)
def test_add_sheetname(): wb = Workbook() with pytest.raises(TypeError): wb._add_sheet("Test")
def test_add_sheet_from_other_workbook(): wb1 = Workbook() wb2 = Workbook() ws = wb1.active with pytest.raises(ValueError): wb2._add_sheet(ws)
def test_add_correct_sheet(): wb = Workbook() new_sheet = wb.create_sheet() wb._add_sheet(new_sheet) assert new_sheet == wb.worksheets[2]