Skip to content

Commit

Permalink
added coveralls support and refactored some code
Browse files Browse the repository at this point in the history
  • Loading branch information
ldgit committed Dec 9, 2015
1 parent 24f447f commit f353455
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = tests/*
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
language: python
install: true
install:
- pip install pytest-cov
- pip install coveralls
python:
- "3.3"
- "2.6"
script: py.test
script:
- py.test --cov-config .coveragerc --cov=. tests/
after_success:
coveralls
8 changes: 2 additions & 6 deletions app/hours_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ def _calculate_total_minutes_from_string(self, time_string):

time_list = time_string.split(':')
hours = int(time_list[0])
try:
minutes = int(time_list[1])
except IndexError:
minutes = 0
minutes = int(time_list[1])

total_minutes = minutes + hours * 60

Expand All @@ -52,5 +49,4 @@ def _is_valid_format(self, hour):
if __name__ == '__main__':
import sys

calc = HoursCalculator()
print(calc.add(*sys.argv[1:]))
print(HoursCalculator().add(*sys.argv[1:]))
3 changes: 1 addition & 2 deletions calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@

class CalculateHoursCommand(sublime_plugin.TextCommand):
def run(self, edit):
command = SublimeCommand()
command.calculate_hours(edit, self.view)
SublimeCommand().calculate_hours(edit, self.view)
1 change: 1 addition & 0 deletions tests/test_hours_calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def test_add_single_negative_hour(self):
def test_add_positive_with_negative_hours(self):
self.assertEqual("00:10", self.calculator.add("1:10", "-1:00"))
self.assertEqual("00:00", self.calculator.add("1:10", "-1:10"))
self.assertEqual("-00:05", self.calculator.add("1:10", "-1:15"))
self.assertEqual("00:05", self.calculator.add("2:10", "-1:65"), 'Negative hour with 65 minutes')

def test_add_multiple_negative_hours(self):
Expand Down

0 comments on commit f353455

Please sign in to comment.