def test_add_not_iterable(self): """Do not suppress TypeError if given non-iterable.""" wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) with pytest.raises(TypeError): sws.add(42)
def test_add_bad_data(self, m_ao): """Warn user when iterable contains bad types instead of halting.""" m_ao.side_effect = TypeError('Bad data, yo!') wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) with pytest.warns(UserWarning): sws.add((1, 2, 3, 4)) assert m_ao.call_count == 4
def test_add(self, m_ao): """add should call add_one for each item in iterable.""" messages = StringIO() wb = Workbook() ws = wb.active sws = SeedsWorksheet(ws) sws.add(('Test',), stream=messages) m_ao.assert_called_with('Test', stream=messages) messages.seek(0) msgs = messages.read() assert '-- BEGIN adding data to SeedsWorksheet. --' in msgs assert '-- END adding data to SeedsWorksheet. --' in msgs