Skip to content

Commit

Permalink
Merge pull request #151 from Freso/flake8-fixups
Browse files Browse the repository at this point in the history
Add flake8 testing to CI
  • Loading branch information
JoeLametta authored May 3, 2017
2 parents fc3cdbf + 99e1463 commit 4fa8c4b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 20 deletions.
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
6 changes: 3 additions & 3 deletions misc/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/>.
14 changes: 7 additions & 7 deletions misc/show-coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ def __init__(self, name, lines, covered):
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'):
Expand All @@ -44,10 +44,10 @@ def show_results(self):
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()
Expand All @@ -61,15 +61,15 @@ def show_one(self, filename):
return

filename = self._strip_filename(filename)

p = Presentation(filename,
len(lines),
len(lines) - len(uncovered_lines))
p.show(self.maxlen)

self.total_lines += p.lines
self.total_covered += p.covered

def main(args):
c = Coverage()
files = args[1:]
Expand All @@ -82,6 +82,6 @@ def main(args):
c.add_file(file)

c.show_results()

if __name__ == '__main__':
sys.exit(main(sys.argv))
2 changes: 0 additions & 2 deletions whipper/common/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,3 @@ def commandMissing(self):
Called when the command is missing.
"""
pass


2 changes: 1 addition & 1 deletion whipper/image/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def setup(self, runner):

# 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
Expand Down
4 changes: 2 additions & 2 deletions whipper/program/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions whipper/test/test_common_mbngs.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,3 @@ def testMalaInCuba(self):
';ec07a209-55ff-4084-bc41-9d4d1764e075'
';f626b92e-07b1-4a19-ad13-c09d690db66c'
)


1 change: 0 additions & 1 deletion whipper/test/test_image_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,3 @@ def testIndexes(self):
self.assertEquals(t.getIndex(2).absolute, 111257 + 3370)

# print self.toc.table.cue()

1 change: 0 additions & 1 deletion whipper/test/test_program_cdparanoia.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,3 @@ def testDefeatsCache(self):
t = AnalyzeFileTask(path)
self.runner.run(t)
self.failUnless(t.defeatsCache)

0 comments on commit 4fa8c4b

Please sign in to comment.