Skip to content

Commit

Permalink
Tests combined into single function using pytest parameterize Answers U…
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSwift1 committed Nov 5, 2020
1 parent 4137013 commit 2a296c4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions week05-testing/test_times_single.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from times import time_range, compute_overlap_time
import pytest
@pytest.mark.parametrize("range1,range2,expected",[
(time_range("2010-01-12 10:00:00", "2010-01-12 12:00:00"),
time_range("2010-01-12 10:30:00", "2010-01-12 10:45:00", 2, 60),
[('2010-01-12 10:30:00', '2010-01-12 10:37:00'), ('2010-01-12 10:38:00', '2010-01-12 10:45:00')]),
(time_range("2019-01-10 10:00:00", "2019-01-10 11:00:00"),
time_range("2019-01-10 11:20:00", "2019-01-10 11:30:00"),
[]),
(time_range("2010-01-12 10:00:00", "2010-01-12 13:00:00",2,60),
time_range("2010-01-12 10:30:00", "2010-01-12 11:35:00", 2, 60),
[('2010-01-12 10:30:00', '2010-01-12 11:02:00'),
('2010-01-12 11:03:00', '2010-01-12 11:29:30'),
('2010-01-12 11:30:30', '2010-01-12 11:35:00')]),
(time_range("2010-01-12 10:00:00", "2010-01-12 13:00:00"),
time_range("2010-01-12 13:00:00", "2010-01-12 14:00:00"),
[('2010-01-12 13:00:00', '2010-01-12 13:00:00')])
])



def test_eval(range1,range2, expected):
assert compute_overlap_time(range1,range2) == expected

def write_backwards_time():
with pytest.raises(ValueError):
large = time_range("2010-01-12 14:00:00", "2010-01-12 13:00:00")

0 comments on commit 2a296c4

Please sign in to comment.