Browse Source

Fix paleolithic python

pull/307/head
Florian Mounier 9 years ago
parent
commit
e9ea1679b5
  1. 2
      pygal/formatters.py
  2. 10
      pygal/test/test_config.py
  3. 2
      pygal/test/test_formatters.py

2
pygal/formatters.py

@ -20,6 +20,8 @@
Formatters to use with `value_formatter` and `x_value_formatter` configs
"""
from __future__ import division
from datetime import datetime, date, time
from math import floor, log
from pygal._compat import u, to_str

10
pygal/test/test_config.py

@ -515,11 +515,11 @@ def test_formatters(Chart):
return
chart = Chart(formatter=lambda x, chart, serie: '%s%s$' % (
x, serie.title))
chart.add('_a', [1, 2, {'value': 3, 'formatter': lambda x: '%s¥' % x}])
chart.add('_b', [4, 5, 6], formatter=lambda x: '%s' % x)
chart.add('_a', [1, 2, {'value': 3, 'formatter': lambda x: u('%s¥') % x}])
chart.add('_b', [4, 5, 6], formatter=lambda x: u('%s') % x)
chart.x_labels = [2, 4, 6]
chart.x_labels_major = [4]
q = chart.render_pyquery()
assert {v.text for v in q(".value")} == set((
'4€', '5€', '6€', '1_a$', '2_a$', '') + (
('6_a$', '15€') if Chart == Pie else ()))
assert set([v.text for v in q(".value")]) == set((
u('4€'), u('5€'), u('6€'), '1_a$', '2_a$', u('')) + (
('6_a$', u('15€')) if Chart == Pie else ()))

2
pygal/test/test_formatters.py

@ -58,7 +58,7 @@ def test_human_readable():
def test_human_readable_custom():
"""Test human_readable formatter option"""
f = formatters.HumanReadable()
assert f(None) == ''
assert f(None) == u('')
f = formatters.HumanReadable(none_char='/')
assert f(None) == '/'

Loading…
Cancel
Save