File: test_core_NWBContainer.py

package info (click to toggle)
pynwb 2.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,316 kB
  • sloc: python: 17,501; makefile: 597; sh: 11
file content (36 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import unittest

from pynwb.core import NWBContainer
from hdmf.utils import docval


class MyTestClass(NWBContainer):

    __nwbfields__ = ('prop1', 'prop2')

    @docval({'name': 'name', 'type': str, 'doc': 'The name of this container'})
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.prop1 = 'test1'


class TestNWBContainer(unittest.TestCase):

    def test_constructor(self):
        """Test constructor
        """
        obj = MyTestClass('obj1')
        self.assertEqual(obj.name, 'obj1')
        obj.prop2 = 'test2'

    def test_nwbfields(self):
        """Test that getters and setters work for nwbfields
        """
        obj = MyTestClass('obj1')
        obj.prop2 = 'test2'
        self.assertEqual(obj.prop1, 'test1')
        self.assertEqual(obj.prop2, 'test2')


if __name__ == '__main__':
    unittest.main()