-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test exercise time #13
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
Small improvements could be done to the negative test.
|
||
with pytest.raises(ValueError): | ||
test1 = time_range("2010-01-12 12:00:00", "2010-01-12 10:00:00") | ||
test2 = time_range("2010-01-12 11:00:00", "2010-01-12 10:30:00") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the code in line 28 raises a ValueError (as it should!) this line will never be executed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also check that the error message is what you expect!
result = compute_overlap_time(large, short) | ||
print(result) | ||
expected = [('2010-01-12 10:30:00', '2010-01-12 10:34:20'), ('2010-01-12 10:35:20', '2010-01-12 10:36:30'), ('2010-01-12 10:38:30', '2010-01-12 10:39:40'), ('2010-01-12 10:40:40', '2010-01-12 10:45:00')] | ||
print(expected) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
This is a good test - but you can see that it gets quite hard to read very quickly. You might want to move some of the data into a fixture - which is in fact homework: UCL-MPHY0021-21-22/RSE-Classwork#22 😉
Created a test file and function to test the overlap function.
Created function for both overlapping and non-overlapping
Answers UCL-MPHY0021-21-22/RSE-Classwork#16