Skip to content

Commit

Permalink
Fix bugged Device constructor (#1209)
Browse files Browse the repository at this point in the history
* Fix bugged device constructor

* Update integration test
  • Loading branch information
rly authored Mar 18, 2020
1 parent 929972d commit 12b0d18
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/pynwb/device.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from hdmf.utils import docval, call_docval_func
from hdmf.utils import docval, call_docval_func, popargs
from . import register_class, CORE_NAMESPACE
from .core import NWBContainer


@register_class('Device', CORE_NAMESPACE)
class Device(NWBContainer):
"""
Metadata about a data acquisition device, e.g., recording system, electrode, microscope.
"""

__nwbfields__ = ('name',
Expand All @@ -19,4 +20,7 @@ class Device(NWBContainer):
{'name': 'manufacturer', 'type': str, 'doc': 'the name of the manufacturer of this device',
'default': None})
def __init__(self, **kwargs):
call_docval_func(super(Device, self).__init__, kwargs)
description, manufacturer = popargs('description', 'manufacturer', kwargs)
call_docval_func(super().__init__, kwargs)
self.description = description
self.manufacturer = manufacturer
4 changes: 3 additions & 1 deletion tests/integration/hdf5/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ class TestDeviceIO(NWBH5IOMixin, TestCase):

def setUpContainer(self):
""" Return the test Device to read/write """
return Device(name='device_name')
return Device(name='device_name',
description='description',
manufacturer='manufacturer')

def addContainer(self, nwbfile):
""" Add the test Device to the given NWBFile """
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
from pynwb.testing import TestCase


class DeviceConstructorBoth(TestCase):
class TestDevice(TestCase):

def test_init(self):
device = Device(name='device_name')
device = Device(name='device_name',
description='description',
manufacturer='manufacturer')

self.assertEqual(device.name, 'device_name')
self.assertEqual(device.description, 'description')
self.assertEqual(device.manufacturer, 'manufacturer')

0 comments on commit 12b0d18

Please sign in to comment.