diff --git a/pygal/graph/base.py b/pygal/graph/base.py index 1bccf3e..639e20f 100644 --- a/pygal/graph/base.py +++ b/pygal/graph/base.py @@ -205,8 +205,8 @@ class BaseGraph(object): def render_to_png(self, filename): import cairosvg - import StringIO - fakefile = StringIO.StringIO() + from io import BytesIO + fakefile = BytesIO() fakefile.write(self.render()) fakefile.seek(0) cairosvg.surface.PNGSurface.convert( diff --git a/pygal/test/test_graph.py b/pygal/test/test_graph.py index 2dcda95..dc43e02 100644 --- a/pygal/test/test_graph.py +++ b/pygal/test/test_graph.py @@ -61,6 +61,6 @@ def test_render_to_png(): line = Line() line.add('Serie 1', [1]) line.render_to_png(file_name) - with open(file_name) as f: + with open(file_name, 'rb') as f: assert f.read() os.remove(file_name)