MCPcopy Create free account
hub / github.com/PyTables/PyTables / test02_setAttributes

Method test02_setAttributes

tables/tests/test_attributes.py:164–186  ·  view source on GitHub ↗

Checking setting large string attributes (Node methods)

(self)

Source from the content-addressed store, hash-verified

162 self.assertRaises(TypeError, self.check_name, 0)
163
164 def test02_setAttributes(self):
165 """Checking setting large string attributes (Node methods)"""
166
167 attrlength = 2048
168 # Try to put a long string attribute on a group object
169 self.root.agroup._f_setattr("attr1", "p" * attrlength)
170 # Now, try with a Table object
171 self.root.atable.set_attr("attr1", "a" * attrlength)
172
173 # Finally, try with an Array object
174 self.root.anarray.set_attr("attr1", "n" * attrlength)
175
176 if self.close:
177 if common.verbose:
178 print("(closing file version)")
179 self._reopen(mode="r+", node_cache_slots=self.node_cache_slots)
180 self.root = self.h5file.root
181
182 self.assertEqual(
183 self.root.agroup._f_getattr("attr1"), "p" * attrlength
184 )
185 self.assertEqual(self.root.atable.get_attr("attr1"), "a" * attrlength)
186 self.assertEqual(self.root.anarray.get_attr("attr1"), "n" * attrlength)
187
188 def test03_setAttributes(self):
189 """Checking setting large string attributes (AttributeSet methods)"""

Callers

nothing calls this directly

Calls 5

_f_setattrMethod · 0.80
_f_getattrMethod · 0.80
get_attrMethod · 0.80
set_attrMethod · 0.45
_reopenMethod · 0.45

Tested by

no test coverage detected