def test_write_legend(self, bar_chart, root_xml): cw = BarChartWriter(bar_chart) cw._write_legend(root_xml) expected = """ <test xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"> <c:legend> <c:legendPos val="r" /><c:layout /> </c:legend> </test>""" xml = tostring(root_xml) diff = compare_xml(xml, expected) assert diff is None, diff
def test_no_write_legend(self, bar_chart, root_xml): cw = BarChartWriter(bar_chart) bar_chart.show_legend = False cw._write_legend(root_xml) children = [e for e in root_xml] assert len(children) == 0