Skip to content
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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Conversation

Susizhou
Copy link

@Susizhou Susizhou commented Nov 3, 2021

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

@Susizhou
Copy link
Author

Susizhou commented Nov 4, 2021

@jkos9

Copy link
Contributor

@alessandrofelder alessandrofelder left a 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")
Copy link
Contributor

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!

Copy link
Contributor

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)
Copy link
Contributor

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 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants