Repository: silx-kit/silx
Issue: [hdf5 test] The process cannot access the file because it is being used by another process

While the GUI tests was disabled, maybe this issue was introduced. Or maybe it appears time to time.

Environment: `PYTHON_DIR=C:\\Python36-x64, QT_BINDING=PyQt5, QT_PINNED_VERSION===5.8.2, WITH_GL_TEST=True`

https://ci.appveyor.com/project/ESRF/silx/build/0.6.0.2325/job/ed9yhf37hdi3im82

```
ERROR: tearDownClass (silx.gui.hdf5.test.test_hdf5.TestH5Node)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\\projects\\silx\\venv_test\\lib\\site-packages\\silx\\gui\\hdf5\\test\\test_hdf5.py", line 502, in tearDownClass
    shutil.rmtree(cls.tmpDirectory)
  File "C:\\projects\\silx\\venv_test\\lib\\shutil.py", line 494, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\\projects\\silx\\venv_test\\lib\\shutil.py", line 389, in _rmtree_unsafe
    onerror(os.unlink, fullname, sys.exc_info())
  File "C:\\projects\\silx\\venv_test\\lib\\shutil.py", line 387, in _rmtree_unsafe
    os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\\\Users\\\\appveyor\\\\AppData\\\\Local\\\\Temp\\\\1\\\\tmp2a02f8w4\\\\base.h5'
```

Changed files:
silx/gui/hdf5/Hdf5Node.py, silx/gui/hdf5/test/test_hdf5.py

diff --git a/silx/gui/hdf5/Hdf5Node.py b/silx/gui/hdf5/Hdf5Node.py
index 1220ac246..0fcb40753 100644
--- a/silx/gui/hdf5/Hdf5Node.py
+++ b/silx/gui/hdf5/Hdf5Node.py
@@ -27,6 +27,8 @@ __authors__ = ["V. Valls"]
 __license__ = "MIT"
 __date__ = "16/06/2017"
 
+import weakref
+
 
 class Hdf5Node(object):
     """Abstract tree node
@@ -43,7 +45,9 @@ class Hdf5Node(object):
             everything is lazy loaded.
         """
         self.__child = None
-        self.__parent = parent
+        self.__parent = None
+        if parent is not None:
+            self.__parent = weakref.ref(parent)
         if populateAll:
             self.__child = []
             self._populateChild(populateAll=True)
@@ -54,7 +58,12 @@ class Hdf5Node(object):
 
         :rtype: Hdf5Node
         """
-        return self.__parent
+        if self.__parent is None:
+            return None
+        parent = self.__parent()
+        if parent is None:
+            self.__parent = parent
+        return parent
 
     def setParent(self, parent):
         """Redefine the parent of the node.
@@ -63,7 +72,10 @@ class Hdf5Node(object):
 
         :param Hdf5Node parent: The new parent
         """
-        self.__parent = parent
+        if parent is None:
+            self.__parent = None
+        else:
+            self.__parent = weakref.ref(parent)
 
     def appendChild(self, child):
         """Append a child to the node.
diff --git a/silx/gui/hdf5/test/test_hdf5.py b/silx/gui/hdf5/test/test_hdf5.py
index 4a8e9cc71..c9c3627cf 100644
--- a/silx/gui/hdf5/test/test_hdf5.py
+++ b/silx/gui/hdf5/test/test_hdf5.py
@@ -29,7 +29,6 @@ __license__ = "MIT"
 __date__ = "01/09/2017"
 
 
-import sys
 import time
 import os
 import unittest
@@ -587,9 +586,6 @@ class TestH5Node(TestCaseQt):
         self.assertEqual(h5node.local_name, "/link/soft_link_to_link")
 
     def testExternalLink(self):
-        if sys.platform == "win32":
-            # FIXME it have to be removed
-            self.skipTest("Creates issue on win32. See https://github.com/silx-kit/silx/issues/1073")
         path = ["base.h5", "link", "external_link"]
         h5node = self.getH5NodeFromPath(self.model, path)
 
@@ -602,9 +598,6 @@ class TestH5Node(TestCaseQt):
         self.assertEqual(h5node.local_name, "/link/external_link")
 
     def testExternalLinkToLink(self):
-        if sys.platform == "win32":
-            # FIXME it have to be removed
-            self.skipTest("Creates issue on win32. See https://github.com/silx-kit/silx/issues/1073")
         path = ["base.h5", "link", "external_link_to_link"]
         h5node = self.getH5NodeFromPath(self.model, path)