Add tests for additional h5py.File exceptions#1258
Conversation
This adds tests for a couple of exceptions that were not yet covered.
There was a problem hiding this comment.
Code Review
This pull request adds unit tests to verify the exception handling of the get_from_file method in the MolecularData class. The new test cases use mocking to simulate KeyError and IOError scenarios, ensuring the method returns None as expected. I have no feedback to provide.
|
What's Jules? |
mpharrigan
left a comment
There was a problem hiding this comment.
it's strange that the desired behavior under test is to swallow the bad inputs and errors and just return None, but if this is for test coverage then ok
It is jules.google.com |
I'm not sure if I understand, but it might worth noting that get_from_file() returns try:
with h5py.File("{}.hdf5".format(self.filename), "r") as f:
data = f[property_name][...]
except KeyError:
data = None
except IOError:
data = None
return dataI'm not sure how else to cover the two paths except to fake an exception and check that data = None. Maybe I'm missing something? |
This adds tests for a couple of exceptions that were not yet covered.
(Tests generated with the help of Jules.)