pynwb.testing.testh5io module¶
- class pynwb.testing.testh5io.NWBH5IOMixin[source]¶
Bases:
object
Mixin class for methods to run a roundtrip test writing an NWB file with an Container and reading the Container from the NWB file. The setUp, test_roundtrip, and tearDown methods will be run by unittest.
The abstract methods setUpContainer, addContainer, and getContainer needs to be implemented by classes that include this mixin.
Example:
class TestMyContainerIO(NWBH5IOMixin, TestCase): def setUpContainer(self): # return a test Container to read/write def addContainer(self, nwbfile): # add the test Container to an NWB file def getContainer(self, nwbfile): # return the test Container from an NWB file
This code is adapted from hdmf.testing.H5RoundTripMixin.
- test_roundtrip()[source]¶
Test whether the read Container has the same contents as the original Container and validate the file.
- test_roundtrip_export()[source]¶
Test whether the test Container read from an exported file has the same contents as the original test Container and validate the file
- roundtripContainer(cache_spec=True)[source]¶
Add the Container to an NWBFile, write it to file, read the file, and return the Container from the file.
- class pynwb.testing.testh5io.AcquisitionH5IOMixin[source]¶
Bases:
NWBH5IOMixin
Mixin class for methods to run a roundtrip test writing an NWB file with an Container as an acquisition and reading the Container as an acquisition from the NWB file. The setUp, test_roundtrip, and tearDown methods will be run by unittest.
The abstract method setUpContainer needs to be implemented by classes that include this mixin.
Example:
class TestMyContainerIO(NWBH5IOMixin, TestCase): def setUpContainer(self): # return a test Container to read/write
This code is adapted from hdmf.testing.H5RoundTripMixin.
- class pynwb.testing.testh5io.NWBH5IOFlexMixin[source]¶
Bases:
object
Mixin class that includes methods to run a flexible roundtrip test. The setUp, test_roundtrip, and tearDown methods will be run by unittest.
The abstract methods getContainerType, addContainer, and getContainer must be implemented by classes that includethis mixin.
Example:
class TestMyContainerIO(NWBH5IOFlexMixin, TestCase): def getContainerType(self): # return the name of the type of Container being tested, for test ID purposes def addContainer(self): # add the test Container to the test NWB file def getContainer(self, nwbfile): # return the test Container from an NWB file
This class is more flexible than NWBH5IOMixin and should be used for new roundtrip tests.
This code is adapted from hdmf.testing.H5RoundTripMixin.
- abstract getContainerType() str [source]¶
Return the name of the type of Container being tested, for test ID purposes.
- abstract addContainer()[source]¶
Add the test Container to the NWBFile.
The NWBFile is accessible from self.nwbfile. The Container should be accessible from getContainer(self.nwbfile).
- test_roundtrip()[source]¶
Test whether the read Container has the same contents as the original Container and validate the file.
- test_roundtrip_export()[source]¶
Test whether the test Container read from an exported file has the same contents as the original test Container and validate the file.
- roundtripContainer(cache_spec=True)[source]¶
Write the file, validate the file, read the file, and return the Container from the file.