Skip to content

Commit

Permalink
Do not use enterContext
Browse files Browse the repository at this point in the history
Using this method the clean up is called after tearDown and that causes
an error on windows.
  • Loading branch information
pmrv committed Oct 9, 2024
1 parent 6c85ac1 commit 486a9bc
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,16 +570,15 @@ def setUp(self):
# Test with an append mode file cache, if test request read mode files
# it will still receive the cached handle
cache = CachedHDF(self.file_name, "a")
if sys.version_info.major == 3 and sys.version_info.minor >= 11:
self.enterContext(cache)
else:
# Poor man's enterContext, because that only landed in 3.11
self._context = cache
cache.__enter__()
# Poor man's enterContext, it seems if enterContext is used the clean
# up action is only performed after the tearDown and so tearDown and
# context manager contest the underlying hdf5 files and that causes
# errors on windows
self._context = cache
cache.__enter__()

def tearDown(self):
if sys.version_info.major == 3 and sys.version_info.minor < 11:
self._context.__exit__(None, None, None)
self._context.__exit__(None, None, None)
super().tearDown()

class TestBaseHierachicalCached(CachedTestMixin, TestBaseHierachical):
Expand Down

0 comments on commit 486a9bc

Please sign in to comment.