Browse Source

Add test for unicode in labels for python2/3. References #16

pull/35/head
Florian Mounier 12 years ago
parent
commit
e1cb23999b
  1. 66
      pygal/test/test_graph.py

66
pygal/test/test_graph.py

@ -19,7 +19,9 @@
import os import os
import pygal import pygal
import uuid import uuid
import sys
from pygal.util import cut from pygal.util import cut
from pygal._compat import u
from pygal.test import pytest_generate_tests, make_data from pygal.test import pytest_generate_tests, make_data
@ -212,3 +214,67 @@ def test_no_data_with_lists_of_nones(Chart):
chart.add('Serie2', [None, None, None]) chart.add('Serie2', [None, None, None])
q = chart.render_pyquery() q = chart.render_pyquery()
assert q(".text-overlay text").text() == "No data" assert q(".text-overlay text").text() == "No data"
def test_unicode_labels_decode(Chart):
chart = Chart()
chart.add(u('Série1'), [{
'value': 1,
'xlink': 'http://1/',
'label': u('{\}°ijæð©&×&<—×€¿_…\{_…')
}, {
'value': 2,
'xlink': {
'href': 'http://6.example.com/'
},
'label': u('æ°€≠|€æ°€əæ')
}, {
'value': 3,
'label': 'unicode <3'
}])
chart.x_labels = [u(''), u('¿?'), u('††††††††'), 'unicode <3']
q = chart.render_pyquery()
def test_unicode_labels_python2(Chart):
if sys.version_info[0] == 3:
return
chart = Chart()
chart.add(u('Série1'), [{
'value': 1,
'xlink': 'http://1/',
'label': eval("u'{\}°ijæð©&×&<—×€¿_…\{_…'")
}, {
'value': 2,
'xlink': {
'href': 'http://6.example.com/'
},
'label': eval("u'æ°€≠|€æ°€əæ'")
}, {
'value': 3,
'label': eval("'unicode <3'")
}])
chart.x_labels = eval("[u'', u'¿?', u'††††††††', 'unicode <3']")
q = chart.render_pyquery()
def test_unicode_labels_python3(Chart):
if sys.version_info[0] == 2:
return
chart = Chart()
chart.add(u('Série1'), [{
'value': 1,
'xlink': 'http://1/',
'label': eval("'{\}°ijæð©&×&<—×€¿_…\{_…'")
}, {
'value': 2,
'xlink': {
'href': 'http://6.example.com/'
},
'label': eval("'æ°€≠|€æ°€əæ'")
}, {
'value': 3,
'label': eval("b'unicode <3'")
}])
chart.x_labels = eval("['', '¿?', '††††††††', 'unicode <3']")
q = chart.render_pyquery()

Loading…
Cancel
Save