Merge pull request #151 from Freso/flake8-fixups

Add flake8 testing to CI
This commit is contained in:
JoeLametta
2017-05-03 16:40:20 +02:00
committed by GitHub
9 changed files with 24 additions and 20 deletions

View File

@@ -2,6 +2,14 @@ sudo: required
language: bash
env:
- FLAKE8=false
- FLAKE8=true
matrix:
allow_failures:
- env: FLAKE8=true
install:
# Dependencies
- sudo apt-get -qq update
@@ -11,6 +19,7 @@ install:
# Testing dependencies
- sudo apt-get -qq install python-twisted-core
- sudo pip install flake8
# Build bundled C utils
- cd src
@@ -21,4 +30,5 @@ install:
- sudo python setup.py install
script:
- python -m unittest discover
- if [ ! "$FLAKE8" = true ]; then python -m unittest discover; fi
- if [ "$FLAKE8" = true ]; then flake8 --benchmark --statistics; fi

View File

@@ -4,16 +4,16 @@
# Copyright (C) 2009 Thomas Vander Stichele
# This file is part of whipper.
#
#
# whipper is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
#
# whipper is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# You should have received a copy of the GNU General Public License
# along with whipper. If not, see <http://www.gnu.org/licenses/>.

View File

@@ -15,14 +15,14 @@ class Presentation:
def show(self, maxlen=20):
format = '%%-%ds %%3d %%%% (%%4d / %%4d)' % maxlen
print format % (self.name, self.percent, self.covered, self.lines)
class Coverage:
def __init__(self):
self.files = []
self.total_lines = 0
self.total_covered = 0
def _strip_filename(self, filename):
filename = os.path.basename(filename)
if filename.endswith('.cover'):
@@ -44,10 +44,10 @@ class Coverage:
for file in self.files:
self.show_one(file)
print '-' * (self.maxlen + 23)
p = Presentation('Total', self.total_lines, self.total_covered)
p.show(self.maxlen)
def show_one(self, filename):
f = open(filename)
lines = [line for line in f.readlines()
@@ -61,7 +61,7 @@ class Coverage:
return
filename = self._strip_filename(filename)
p = Presentation(filename,
len(lines),
len(lines) - len(uncovered_lines))
@@ -69,7 +69,7 @@ class Coverage:
self.total_lines += p.lines
self.total_covered += p.covered
def main(args):
c = Coverage()
files = args[1:]
@@ -82,6 +82,6 @@ def main(args):
c.add_file(file)
c.show_results()
if __name__ == '__main__':
sys.exit(main(sys.argv))

View File

@@ -145,5 +145,3 @@ class PopenTask(task.Task):
Called when the command is missing.
"""
pass

View File

@@ -82,7 +82,7 @@ class Image(object):
# CD's have a standard lead-in time of 2 seconds;
# checksums that use it should add it there
if verify.lengths.has_key(0):
if 0 in verify.lengths:
offset = verify.lengths[0]
else:
offset = self.cue.table.tracks[0].getIndex(1).relative

View File

@@ -18,8 +18,8 @@ def load_device(device):
"""
logger.debug("loading (eject -t) device %s", device)
os.system('eject -t %s' % device)
def unmount_device(device):
"""
Unmount the given device if it is mounted, as happens with automounted

View File

@@ -114,5 +114,3 @@ class MetadataTestCase(unittest.TestCase):
';ec07a209-55ff-4084-bc41-9d4d1764e075'
';f626b92e-07b1-4a19-ad13-c09d690db66c'
)

View File

@@ -442,4 +442,3 @@ class SurferRosaTestCase(common.TestCase):
self.assertEquals(t.getIndex(2).absolute, 111257 + 3370)
# print self.toc.table.cue()

View File

@@ -91,4 +91,3 @@ class CacheTestCase(common.TestCase):
t = AnalyzeFileTask(path)
self.runner.run(t)
self.failUnless(t.defeatsCache)