Browse Source

Add flake8 to tests. Fix style

pull/242/head
Florian Mounier 9 years ago
parent
commit
c4ee92106c
  1. 1
      .gitignore
  2. 8
      demo/moulinrouge/tests.py
  3. 1
      docs/changelog.rst
  4. 4
      docs/contributing.rst
  5. 2
      perf.py
  6. 2
      pygal/graph/base.py
  7. 2
      pygal/graph/public.py
  8. 2
      pygal/state.py
  9. 4
      pygal/svg.py
  10. 4
      pygal/test/test_box.py
  11. 15
      pygal/test/test_date.py
  12. 1
      pygal/test/test_interpolate.py
  13. 2
      pygal/test/test_pie.py
  14. 2
      pygal/test/test_stacked.py
  15. 29
      pygal/test/test_style.py
  16. 1
      pygal/test/test_util.py
  17. 2
      pygal/test/test_view.py
  18. 5
      setup.cfg
  19. 3
      tox.ini

1
.gitignore vendored

@ -9,3 +9,4 @@ dist
coverage-py*
junit-py*
docs/_build
.cache

8
demo/moulinrouge/tests.py

@ -26,7 +26,7 @@ from pygal.style import styles, Style, RotateStyle
from pygal.colors import rotate
from pygal.graph.horizontal import HorizontalGraph
from random import randint, choice
from datetime import datetime, date, time
from datetime import datetime, date
def get_test_routes(app):
@ -369,9 +369,9 @@ def get_test_routes(app):
@app.route('/test/stacked')
def test_stacked():
stacked = StackedBar()
stacked.add('1', [1, 2, 3])
stacked.add('2', [4, 5, 6])
stacked = StackedLine(stack_from_top=True, logarithmic=True)
stacked.add('1', [1, 2])
stacked.add('2', [10, 12])
return stacked.render_response()
@app.route('/test/stacked/reverse')

1
docs/changelog.rst

@ -24,6 +24,7 @@ Changelog
* Transform min_scale and max_scale as options
* mode option has been renamed to a less generic name: box_mode
* fix stack_from_top for stacked lines
* Add flake8 test to py.test in tox
1.7.0
=====

4
docs/contributing.rst

@ -12,7 +12,7 @@ Submit your bug reports and feature requests to the `github bug tracker <http://
Code style
==========
The pygal code tries to respect the `pep8 <https://www.python.org/dev/peps/pep-0008/>`_ please keep that in mind when writing code for pygal.
The pygal code tries to respect the `pep8 <https://www.python.org/dev/peps/pep-0008/>`_ please keep that in mind when writing code for pygal. (The code style is checked along witht the unit tests, see next paragraph).
Testing
@ -25,7 +25,7 @@ To do this install ``py.test`` and them run ``py.test`` in the root of your pyga
.. code-block:: bash
[dev@dev pygal/]$ py.test
[dev@dev pygal/]$ py.test --flake8
Even better if you have several python versions installed you can run ``tox``.

2
perf.py

@ -42,6 +42,7 @@ def perf(chart_name, length, series):
if '--bench' in sys.argv:
bench = True
def prt(s):
pass
@ -49,6 +50,7 @@ if '--bench' in sys.argv:
sys.stdout.write(s)
else:
bench = False
def prt(s):
sys.stdout.write(s)
sys.stdout.flush()

2
pygal/graph/base.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# This file is part of pygal
#
# A python svg graph plotting library

2
pygal/graph/public.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# This file is part of pygal
#
# A python svg graph plotting library

2
pygal/state.py

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
# This file is part of pygal
#
# A python svg graph plotting library

4
pygal/svg.py

@ -228,8 +228,8 @@ class Svg(object):
line = ' '.join([coord_format(c)
for c in coords[origin_index + 1:]
if None not in c])
return self.node(node, 'path',
d=root % (origin, line), **kwargs)
return self.node(
node, 'path', d=root % (origin, line), **kwargs)
def slice(
self, serie_node, node, radius, small_radius,

4
pygal/test/test_box.py

@ -129,8 +129,9 @@ def test_quartiles_tukey():
assert 75 in outliers
assert 77 in outliers
def test_quartiles_stdev():
a = [35, 42, 35, 41, 36, 6, 12, 51, 33, 27, 46, 36, 44, 53, 75, 46, 16,\
a = [35, 42, 35, 41, 36, 6, 12, 51, 33, 27, 46, 36, 44, 53, 75, 46, 16,
51, 45, 29, 25, 26, 54, 61, 27, 40, 23, 34, 51, 37]
SD = 14.67
(min_s, q0, q1, q2, q3, q4, max_s), outliers = Box._box_points(
@ -148,6 +149,7 @@ def test_quartiles_stdev():
assert min_s == q0 == q1 == q2 == q3 == q4 == max_s == b[0]
assert outliers == []
def test_simple_box():
box = ghostedBox()
box.add('test1', [-1, 2, 3, 3.1, 3.2, 4, 5])

15
pygal/test/test_date.py

@ -45,8 +45,7 @@ def test_date():
'2013-02-04',
'2013-02-09',
'2013-02-14',
'2013-02-18'
]
'2013-02-18']
def test_time():
@ -68,8 +67,7 @@ def test_time():
'11:06:40',
'13:53:20',
'16:40:00',
'19:26:40'
]
'19:26:40']
def test_datetime():
@ -96,8 +94,7 @@ def test_datetime():
'2013-02-04T18:46:40',
'2013-02-09T09:53:20',
'2013-02-14T01:00:00',
'2013-02-18T16:06:40'
]
'2013-02-18T16:06:40']
def test_timedelta():
@ -118,8 +115,7 @@ def test_timedelta():
'3 days, 11:20:00',
'4 days, 15:06:40',
'5 days, 18:53:20',
'6 days, 22:40:00'
]
'6 days, 22:40:00']
def test_date_xrange():
@ -142,5 +138,4 @@ def test_date_xrange():
'2013-01-24',
'2013-02-04',
'2013-02-16',
'2013-02-27'
]
'2013-02-27']

1
pygal/test/test_interpolate.py

@ -73,6 +73,7 @@ def test_hermite_cardinal(Chart, datas):
chart = make_data(chart, datas)
assert chart.render()
def test_hermite_catmull_rom(Chart, datas):
chart = Chart(interpolate='hermite',
interpolation_parameters={'type': 'catmull_rom'})

2
pygal/test/test_pie.py

@ -16,8 +16,6 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
import os
import uuid
from pygal import Pie

2
pygal/test/test_stacked.py

@ -34,7 +34,7 @@ def test_stacked_line_reverse():
stacked.add('ten_twelve', [10, 12])
q = stacked.render_pyquery()
assert set(q("desc.value").text().split(' ')) == set(
('11', '14', '1', '2'))
('11', '14', '10', '12'))
def test_stacked_line_log():

29
pygal/test/test_style.py

@ -44,34 +44,37 @@ def test_parametric_styles_with_parameters():
line.x_labels = 'abc'
assert line.render()
def test_stroke_style():
s = Style(stroke_style = 'round')
s = Style(stroke_style='round')
assert s.stroke_style == 'round'
s = Style(stroke_style = 'bevel')
s = Style(stroke_style='bevel')
assert s.stroke_style == 'bevel'
s = Style(stroke_style = 'miter')
s = Style(stroke_style='miter')
assert s.stroke_style == 'miter'
s = Style(stroke_style = 'rounded')
s = Style(stroke_style='rounded')
assert s.stroke_style == 'round'
s = Style(stroke_style = 'invalid derp')
s = Style(stroke_style='invalid derp')
assert s.stroke_style == 'round'
def test_stroke_dasharray():
s = Style(stroke_dasharray = (0,0))
s = Style(stroke_dasharray=(0, 0))
assert s.stroke_dasharray == '0,0'
s = Style(stroke_dasharray = (.5,.5))
s = Style(stroke_dasharray=(.5, .5))
assert s.stroke_dasharray == '0,0'
s = Style(stroke_dasharray = (.9,.9))
s = Style(stroke_dasharray=(.9, .9))
assert s.stroke_dasharray == '0,0'
s = Style(stroke_dasharray = (1.9,1.9))
s = Style(stroke_dasharray=(1.9, 1.9))
assert s.stroke_dasharray == '1,1'
def test_stroke_dasharray_input_types():
s = Style(stroke_dasharray = (0,0))
s = Style(stroke_dasharray=(0, 0))
assert s.stroke_dasharray == '0,0'
s = Style(stroke_dasharray = '0,0')
s = Style(stroke_dasharray='0,0')
assert s.stroke_dasharray == '0,0'
s = Style(stroke_dasharray = '0x0')
s = Style(stroke_dasharray='0x0')
assert s.stroke_dasharray == '0,0'
s = Style(stroke_dasharray = '0 0')
s = Style(stroke_dasharray='0 0')
assert s.stroke_dasharray == '0,0'

1
pygal/test/test_util.py

@ -16,7 +16,6 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
from datetime import time
from pygal._compat import u
from pygal.util import (
round_to_int, round_to_float, _swap_curly, template, humanize,

2
pygal/test/test_view.py

@ -17,8 +17,6 @@
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
from pygal.test import make_data
def test_all_logarithmic(Chart):
chart = Chart(logarithmic=True)

5
setup.cfg

@ -0,0 +1,5 @@
[pytest]
flake8-ignore =
pygal/__init__.py F401
pygal/_compat.py F821
docs/conf.py ALL

3
tox.ini

@ -4,6 +4,7 @@ envlist = py26,py27,py32,py33,py34,pypy
[testenv]
deps =
pytest
pytest-flake8
coverage
lxml
pyquery
@ -13,5 +14,5 @@ setenv =
COVERAGE_FILE=.cov-{envname}
commands =
coverage run --source=pygal {envbindir}/py.test pygal/test --junitxml=junit-{envname}.xml
coverage run --source=pygal {envbindir}/py.test pygal/test --junitxml=junit-{envname}.xml --flake8
coverage xml -o coverage-{envname}.xml

Loading…
Cancel
Save