Test getting a child of a closed node.
(self)
| 1762 | # self.assertRaises(FileModeError, self.h5file.disable_undo) |
| 1763 | |
| 1764 | def test19a_getNode(self): |
| 1765 | """Test getting a child of a closed node.""" |
| 1766 | |
| 1767 | g1 = self.h5file.create_group("/", "g1") |
| 1768 | g2 = self.h5file.create_group("/g1", "g2") |
| 1769 | |
| 1770 | # Close this *object* so that it should not be used. |
| 1771 | g1._f_close() |
| 1772 | self.assertRaises(tb.ClosedNodeError, g1._f_get_child, "g2") |
| 1773 | |
| 1774 | # Getting a node by its closed object is not allowed. |
| 1775 | self.assertRaises(tb.ClosedNodeError, self.h5file.get_node, g1) |
| 1776 | |
| 1777 | # Going through that *node* should reopen it automatically. |
| 1778 | try: |
| 1779 | g2_ = self.h5file.get_node("/g1/g2") |
| 1780 | except tb.ClosedNodeError: |
| 1781 | self.fail("closed parent group has not been reopened") |
| 1782 | |
| 1783 | # Already open nodes should be closed now, but not the new ones. |
| 1784 | self.assertIs( |
| 1785 | g2._v_isopen, |
| 1786 | False, |
| 1787 | "open child of closed group has not been closed", |
| 1788 | ) |
| 1789 | self.assertIs( |
| 1790 | g2_._v_isopen, |
| 1791 | True, |
| 1792 | "open child of closed group has not been closed", |
| 1793 | ) |
| 1794 | |
| 1795 | # And existing closed ones should remain closed, but not the new ones. |
| 1796 | g1_ = self.h5file.get_node("/g1") |
| 1797 | self.assertIs( |
| 1798 | g1._v_isopen, False, "already closed group is not closed anymore" |
| 1799 | ) |
| 1800 | self.assertIs( |
| 1801 | g1_._v_isopen, True, "newly opened group is still closed" |
| 1802 | ) |
| 1803 | |
| 1804 | def test19b_getNode(self): |
| 1805 | """Test getting a node that does not start with a slash ('/').""" |
nothing calls this directly
no test coverage detected