Browse Source

Add inline css + css tests

pull/98/head
Florian Mounier 11 years ago
parent
commit
0a481165f0
  1. 3
      pygal/svg.py
  2. 26
      pygal/test/test_config.py

3
pygal/svg.py

@ -73,6 +73,9 @@ class Svg(object):
self.processing_instructions.append(
etree.PI(
u('xml-stylesheet'), u('href="%s"' % css)))
else:
if css.startswith('inline:'):
css_text = css[len('inline:'):]
else:
if not os.path.exists(css):
css = os.path.join(

26
pygal/test/test_config.py

@ -288,3 +288,29 @@ def test_include_x_axis(Chart):
chart.include_x_axis = True
q = chart.render_pyquery()
assert '0.0' in q(yaxis).map(texts)
def test_css(Chart):
css = "{{ id }}text { fill: #bedead; }\n"
css_file = '/tmp/pygal_custom_style.css'
with open(css_file, 'w') as f:
f.write(css)
config = Config()
config.css.append(css_file)
chart = Chart(config)
chart.add('/', [10, 1, 5])
svg = chart.render().decode('utf-8')
assert '#bedead' in svg
def test_inline_css(Chart):
css = "{{ id }}text { fill: #bedead; }\n"
config = Config()
config.css.append('inline:' + css)
chart = Chart(config)
chart.add('/', [10, 1, 5])
svg = chart.render().decode('utf-8')
assert '#bedead' in svg

Loading…
Cancel
Save