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.

setUp()[source]
tearDown()[source]
abstract setUpContainer()[source]

Should return the test Container to read/write

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.

roundtripExportContainer(cache_spec=True)[source]

Add the test Container to an NWBFile, write it to file, read the file, export the read NWBFile to another file, and return the test Container from the file

abstract addContainer(nwbfile)[source]

Should add the test Container to the given NWBFile

abstract getContainer(nwbfile)[source]

Should return the test Container from the given NWBFile

validate()[source]

Validate the created files

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.

addContainer(nwbfile)[source]

Add an NWBDataInterface object to the file as an acquisition

getContainer(nwbfile)[source]

Get the NWBDataInterface object from the file

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.

setUp()[source]
tearDown()[source]
get_manager()[source]
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).

abstract getContainer(nwbfile: NWBFile)[source]

Return the test Container from the given 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.

roundtripExportContainer(cache_spec=True)[source]

Roundtrip the container, then export the read NWBFile to a new file, validate the files, and return the test Container from the file.

validate()[source]

Validate the created files.