コード例 #1
0
 def test_store(self):
     fun = sys._getframe().f_code.co_name
     print("Run: %s.%s() " % (self.__class__.__name__, fun))
     el = Element(self._tfname, self._fattrs2)
     el2 = EDim(self._fattrs2, el)
     self.assertEqual(el2.tagName, self._tfname)
     self.assertEqual(el2.content, [])
     self.assertEqual(el2._tagAttrs, self._fattrs2)
     self.assertEqual(el2.doc, "")
     self.assertEqual(el2.store(""), None)
     self.assertEqual(el2.last, el)
     self.assertEqual(el2.store("<tag/>"), None)
コード例 #2
0
ファイル: EDimH5PY_test.py プロジェクト: nexdatas/writer
    def test_store_last_index2(self):
        fun = sys._getframe().f_code.co_name
        print("Run: %s.%s() " % (self.__class__.__name__, fun))

        fname = "test.h5"
        nxFile = None
        eFile = None

        # gname = "testGroup"
        # gtype = "NXentry"
        # fdname = "testField"
        # fdtype = "int64"

        # file handle
        nxFile = FileWriter.create_file(fname, overwrite=True).root()
        # element file objects
        eFile = EFile([], None, nxFile)

        el = Element(self._tfname, self._fattrs2, eFile)
        fi = EField(self._fattrs2, el)
        el2 = EDimensions(self._fattrs3, fi)
        el3 = EDim(self._attrs5, el2)
        ds = TstDataSource()
        ds.value0d = self.__rnd.randint(1, 10)
        el3.source = ds
        el4 = EDim(self._attrs4, el2)
        ds2 = TstDataSource()
        ds2.value0d = self.__rnd.randint(1, 10)
        el4.source = ds2
        el3.store()
        el4.store()

        self.assertEqual(fi.tagName, "field")
        self.assertEqual(fi.content, [])
        self.assertEqual(fi._tagAttrs, self._fattrs2)
        self.assertEqual(fi.doc, "")
        self.assertEqual(fi._lastObject(), None)
        self.assertEqual(type(el2.last), EField)
        self.assertEqual(el2.last.rank, "2")
        self.assertEqual(el3._beforeLast().lengths, {
            '1': '%s' % ds.value0d,
            '2': '%s' % ds2.value0d
        })
        self.assertEqual(fi.lengths, {
            '1': '%s' % ds.value0d,
            '2': '%s' % ds2.value0d
        })
        self.assertEqual(fi.rank, "2")

        nxFile.close()
        os.remove(fname)