Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cursewords/cursewords.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,12 +627,11 @@ def show_time(self):
x_coord = self.grid.grid_x + self.grid.column_count * 4 - 7

print(self.grid.term.move(y_coord, x_coord)
+ self.display_format())
+ self.format_time(self.time_passed))

def display_format(self):
time_amount = self.time_passed

m, s = divmod(time_amount, 60)
@classmethod
def format_time(cl, time_passed):
m, s = divmod(time_passed, 60)
h, m = divmod(m, 60)

ch = '{h:02d}:'.format(h=h) if h else ' '
Expand Down
1 change: 1 addition & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pytest==4.3.0
4 changes: 4 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
with open(path.join(here, 'requirements.txt')) as f:
reqs = f.read().split()

with open(path.join(here, 'requirements.dev.txt')) as f:
test_reqs = f.read().split()

with open(path.join(here, 'README.md')) as f:
readme = f.read()

Expand All @@ -30,6 +33,7 @@
packages=find_packages(),
python_requires='>=3.4',
install_requires=reqs,
tests_require=test_reqs,
package_data={
'cursewords': ['version']
},
Expand Down
13 changes: 13 additions & 0 deletions test/cursewords_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import cursewords

def test_format_time():
test_cases = [
(1, " 00:01"),
(61, " 01:01"),
(314, " 05:14"),
(1288, " 21:28"),
(1288, " 21:28"),
(3723, "01:02:03"),
]
for (seconds, expect) in test_cases:
assert cursewords.Timer.format_time(seconds) == expect