Skip to content

Commit

Permalink
Disable no lxml under python 2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
paradoxxxzero committed Jul 10, 2015
1 parent 9c07914 commit 2ddf8b5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 17 deletions.
37 changes: 28 additions & 9 deletions demo/moulinrouge/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,21 +453,40 @@ def test_worldmap():
'value': ('mw', 40),
'label': 'Last'
}])
wmap.add('6th', [3, 5, 34, 12])
wmap.title = 'World Map !!'
return wmap.render_response()

@app.route('/test/supranational')
def test_supranational():
wmap = world.SupranationalWorld(style=choice(list(styles.values())))

wmap.add('Asia', [('asia', 1)])
wmap.add('Europe', [('europe', 1)])
wmap.add('Africa', [('africa', 1)])
wmap.add('North america', [('north_america', 1)])
wmap.add('South america', [('south_america', 1)])
wmap.add('Oceania', [('oceania', 1)])
wmap.add('Antartica', [('antartica', 1)])
v = [
('europe', 0),
('oceania', 2),
('antartica', 4),
('south_america', 5),
('africa', 6),
('north_america', 7),
('asia', 8)
]
wmap.add('Serie with metadata', [
v[0],
{'value': v[1]},
{'value': v[2], 'label': 'Three'},
{'value': v[3], 'xlink': 'http://4.example.com/'},
{'value': v[4], 'xlink': 'http://5.example.com/', 'label': 'Five'},
{'value': v[5], 'xlink': {
'href': 'http://6.example.com/'}, 'label': 'Six'},
{'value': v[6], 'xlink': {
'href': 'http://7.example.com/',
'target': '_blank'}, 'label': 'Seven'}
])
# wmap.add('Asia', [('asia', 1)])
# wmap.add('Europe', [('europe', 1)])
# wmap.add('Africa', [('africa', 1)])
# wmap.add('North america', [('north_america', 1)])
# wmap.add('South america', [('south_america', 1)])
# wmap.add('Oceania', [('oceania', 1)])
# wmap.add('Antartica', [('antartica', 1)])

wmap.title = 'Supra World Map !!'
return wmap.render_response()
Expand Down
10 changes: 3 additions & 7 deletions pygal/graph/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,15 @@ def _plot(self):
ratio = 1
else:
ratio = .3 + .7 * (value - min_) / (max_ - min_)

try:
areae = map.findall(
".//*[@class='%s%s %s map-element']" % (
self.area_prefix, area_code,
self.kind))
except SyntaxError:
# Python 2.6 (you'd better install lxml)
areae = []
for g in map:
for e in g:
if '%s%s' % (
self.area_prefix, area_code
) in e.attrib.get('class', ''):
areae.append(e)
raise ImportError('lxml is required under python 2.6')

if not areae:
continue
Expand Down Expand Up @@ -105,6 +100,7 @@ def _plot(self):
else:
title_node = self.svg.node(area, 'title')
text = ''

title_node.text = text + '[%s] %s: %s' % (
serie.title,
self.area_names[area_code], self._format(value))
Expand Down
6 changes: 5 additions & 1 deletion pygal/test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import pytest
import pygal
from pygal.etree import etree
import sys
from . import get_data


Expand All @@ -32,9 +33,12 @@ def etreefx(request):


def pytest_generate_tests(metafunc):
if etree._lxml_etree:
if etree._lxml_etree and sys.version_info[:2] != (2, 6):
metafunc.fixturenames.append('etreefx')
metafunc.parametrize('etreefx', ['lxml', 'etree'], indirect=True)
if sys.version_info[:2] != (2, 6):
if not etree._lxml_etree:
raise ImportError('lxml is required under python 2.6')

if "Chart" in metafunc.funcargnames:
metafunc.parametrize("Chart", pygal.CHARTS)
Expand Down

0 comments on commit 2ddf8b5

Please sign in to comment.