def test_values(self, Worksheet): ws = Worksheet(Workbook()) ws.append([1, 2, 3]) ws.append([4, 5, 6]) vals = ws.values assert next(vals) == (1, 2, 3) assert next(vals) == (4, 5, 6)
def test_append_dict_index(self, Worksheet): ws = Worksheet(Workbook()) ws.append({1: 'This is A1', 3: 'This is C1'}) assert 'This is A1' == ws['A1'].value assert 'This is C1' == ws['C1'].value
def test_append_dict_letter(self, Worksheet): ws = Worksheet(Workbook()) ws.append({'A': 'This is A1', 'C': 'This is C1'}) assert 'This is A1' == ws['A1'].value assert 'This is C1' == ws['C1'].value
def test_append_list(self, Worksheet): ws = Worksheet(Workbook()) ws.append(['This is A1', 'This is B1']) assert 'This is A1' == ws['A1'].value assert 'This is B1' == ws['B1'].value
def test_append_iterator(self, Worksheet): def itty(): for i in range(30): yield i ws = Worksheet(Workbook()) gen = itty() ws.append(gen) assert ws['AD1'].value == 29
def test_append_cell(self, Worksheet): from openpyxl25.cell.cell import Cell cell = Cell(None, 'A', 1, 25) ws = Worksheet(Workbook()) ws.append([]) ws.append([cell]) assert ws['A2'].value == 25
def test_max_row(Worksheet): ws = Worksheet(DummyWorkbook()) ws.append([]) ws.append([5]) ws.append([]) ws.append([4]) assert ws.max_row == 4
def test_append_2d_list(self, Worksheet): ws = Worksheet(Workbook()) ws.append(['This is A1', 'This is B1']) ws.append(['This is A2', 'This is B2']) vals = ws.iter_rows(min_row=1, min_col=1, max_row=2, max_col=2) expected = ( ('This is A1', 'This is B1'), ('This is A2', 'This is B2'), ) for e, v in zip(expected, ws.values): assert e == tuple(v)
def test_append_range(self, Worksheet): ws = Worksheet(Workbook()) ws.append(range(30)) assert ws['AD1'].value == 29
def test_bad_append(self, Worksheet): ws = Worksheet(Workbook()) with pytest.raises(TypeError): ws.append("test")
def test_append(self, Worksheet): ws = Worksheet(Workbook()) ws.append(['value']) assert ws['A1'].value == "value"