Skip to content

Commit

Permalink
Flake8 the code. (#41)
Browse files Browse the repository at this point in the history
Plus Flake8 only once and put config to setup.cfg.
  • Loading branch information
Michael Howitz committed Feb 28, 2019
1 parent 3da9dee commit 4ff3d6e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
language: python
sudo: false
python:
- 2.7
- 3.5
Expand All @@ -8,18 +7,20 @@ matrix:
include:
- python: "3.7"
dist: xenial
sudo: true
- python: 2.7
name: "Flake8"
install: pip install -U flake8
script: flake8 src setup.py
after_success:
install:
- pip install coveralls coverage
- pip install zc.buildout
- pip install -U six==1.10.0
- pip install flake8
- buildout bootstrap
- buildout

script:
- coverage run bin/test -v1
- flake8 --doctests src tests setup.py
after_success:
- coverage combine
- coveralls
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ ignore =
bootstrap.py

[flake8]
ignore = N801,N802,N803,N805,N806,N812,E301
ignore = N801,N802,N803,N805,N806,N812,E301,W504
exclude = bootstrap.py
max-complexity = 70
doctests = true

[bdist_wheel]
universal = 1
Expand Down
16 changes: 8 additions & 8 deletions src/DocumentTemplate/tests/test_DT_In.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def test_DT_In__InClass____init__1(self):
'<dtml-var sequence-item>'
'</dtml-in>')
with self.assertRaisesRegex(ParseError, '^prefix is not a simple '):
html(seq=sequence)
html(seq=sequence)

def test_DT_In__InClass____init__2(self):
"""It only allows one else block."""
Expand All @@ -99,7 +99,7 @@ def test_DT_In__InClass____init__2(self):
'Still no items available'
'</dtml-in>')
with self.assertRaisesRegex(ParseError, '^too many else blocks'):
html(seq=[])
html(seq=[])

def test_DT_In__InClass____init__3(self):
"""It restricts certain args to batch processing."""
Expand All @@ -114,7 +114,7 @@ def test_DT_In__InClass____init__3(self):
html = self.doc_class(template.format(arg=arg))
error_msg = 'The {arg} attribute was used'.format(arg=arg)
with self.assertRaisesRegex(ParseError, error_msg):
html(seq=['a', 'b'])
html(seq=['a', 'b'])

def test_DT_In__InClass____init__4(self):
"""It does not allow strings as sequence.."""
Expand All @@ -124,7 +124,7 @@ def test_DT_In__InClass____init__4(self):
'<dtml-var sequence-item>'
'</dtml-in>')
with self.assertRaisesRegex(ValueError, 'Strings are not allowed as'):
html(seq="Foo")
html(seq="Foo")

def test_DT_In__InClass____init__5(self):
"""It allows `sequence-item` as sort key resulting in default sort."""
Expand All @@ -148,7 +148,7 @@ def test_DT_In__InClass__renderwob__01(self):
'<dtml-var sequence-item>'
'</dtml-in>')
with self.assertRaisesRegex(ValueError, 'Strings are not allowed as'):
html(seq="Foo")
html(seq="Foo")

def test_DT_In__InClass__renderwob__02(self):
"""It can handle an empty sequence including else."""
Expand Down Expand Up @@ -366,7 +366,7 @@ def test_DT_In__InClass__renderwb__01(self):
'<dtml-var sequence-item>'
'</dtml-in>')
with self.assertRaisesRegex(ValueError, 'Strings are not allowed as'):
html(seq="Foo")
html(seq="Foo")

def test_DT_In__InClass__renderwb__02(self):
"""It can handle an empty sequence including else."""
Expand Down Expand Up @@ -511,7 +511,7 @@ def test_DT_In__make_sortfunction__1(self):
'</dtml-in>')
error_msg = 'sort option must contain no more than 2 slashes'
with self.assertRaisesRegex(SyntaxError, error_msg):
html(seq=seq)
html(seq=seq)

def test_DT_In__make_sortfunction__2(self):
"""It allows only asc and desc as sort order in sort expression."""
Expand All @@ -523,7 +523,7 @@ def test_DT_In__make_sortfunction__2(self):
'</dtml-in>')
error_msg = 'sort oder must be either ASC or DESC'
with self.assertRaisesRegex(SyntaxError, error_msg):
html(seq=seq)
html(seq=seq)

def test_DT_In__make_sortfunction__3(self):
"""It can use a local function for comparison."""
Expand Down
6 changes: 3 additions & 3 deletions src/DocumentTemplate/tests/test_DT_Try.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_DT_Try__Try____init__1(self):
'<dtml-var expr="str(110)">'
'</dtml-try>')
with self.assertRaisesRegex(ParseError, '^No more than one else '):
html()
html()

def test_DT_Try__Try____init__2(self):
"""It allows the else block only in last position."""
Expand Down Expand Up @@ -204,7 +204,7 @@ def test_DT_Try__Try__08(self):
'<dtml-var expr="str(110)">'
'</dtml-try>')
with self.assertRaises(NameError):
html()
html()

def test_DT_Try__Try__09(self):
"""It returns a dtml-return immediately."""
Expand Down Expand Up @@ -234,4 +234,4 @@ def test_DT_Try__Try__10(self):
'<dtml-var expr="str(110)">'
'</dtml-try>')
with self.assertRaises(InvalidErrorTypeExpression):
html()
html()
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ deps =
flake8-html
flake8-debugger
commands =
flake8 --format=html --htmldir={toxinidir}/flake8 --doctests src tests setup.py {posargs}
flake8 --format=html --htmldir={toxinidir}/flake8 src tests setup.py {posargs}

0 comments on commit 4ff3d6e

Please sign in to comment.