From 10bc308c03ea3604592eca98db36a91eb7f791a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Jourdois?= Date: Sat, 31 Oct 2015 16:44:39 +0100 Subject: [PATCH 1/3] Run tests in build directory --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 178db9b..29644b2 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ from setuptools.command.test import test as TestCommand class PyTest(TestCommand): def finalize_options(self): TestCommand.finalize_options(self) - self.test_args = [] + self.test_args = ['-x', 'build/lib/pygal'] self.test_suite = True def run_tests(self): From e8f5553ee8d21343057c64c89987095e9f731112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Jourdois?= Date: Sat, 31 Oct 2015 16:45:50 +0100 Subject: [PATCH 2/3] Open file as utf-8 during tests (copyright symbol) io.open works the same in python2 and in python3 --- pygal/test/test_graph.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pygal/test/test_graph.py b/pygal/test/test_graph.py index ea8c972..8a88246 100644 --- a/pygal/test/test_graph.py +++ b/pygal/test/test_graph.py @@ -24,6 +24,7 @@ import pygal import uuid import sys import pytest +import io from pygal.graph.map import BaseMap from pygal.util import cut from pygal._compat import u @@ -53,7 +54,7 @@ def test_render_to_file(Chart, datas): chart = Chart() chart = make_data(chart, datas) chart.render_to_file(file_name) - with open(file_name) as f: + with io.open(file_name, encoding="utf-8") as f: assert 'pygal' in f.read() os.remove(file_name) From e4dd2747b3c8b8cc359735da013e7a571c4acae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Jourdois?= Date: Sat, 31 Oct 2015 16:47:23 +0100 Subject: [PATCH 3/3] Explicit integers (needed for python 3.5) --- pygal/colors.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygal/colors.py b/pygal/colors.py index bc8ea55..ab33410 100644 --- a/pygal/colors.py +++ b/pygal/colors.py @@ -126,19 +126,19 @@ def unparse_color(r, g, b, a, type): if type == '#rgb': # Don't lose precision on rgb shortcut if r % 17 == 0 and g % 17 == 0 and b % 17 == 0: - return '#%x%x%x' % (r / 17, g / 17, b / 17) + return '#%x%x%x' % (r // 17, g // 17, b // 17) type = '#rrggbb' if type == '#rgba': if r % 17 == 0 and g % 17 == 0 and b % 17 == 0: - return '#%x%x%x%x' % (r / 17, g / 17, b / 17, a * 15) + return '#%x%x%x%x' % (r // 17, g // 17, b // 17, int(a * 15)) type = '#rrggbbaa' if type == '#rrggbb': return '#%02x%02x%02x' % (r, g, b) if type == '#rrggbbaa': - return '#%02x%02x%02x%02x' % (r, g, b, a * 255) + return '#%02x%02x%02x%02x' % (r, g, b, int(a * 255)) if type == 'rgb': return 'rgb(%d, %d, %d)' % (r, g, b)