From c90fc078cb7691778610a2bb3f06694b36ff1d4b Mon Sep 17 00:00:00 2001 From: dh00601 <dh00601@surrey.ac.uk> Date: Sat, 8 Jan 2022 12:27:20 +0000 Subject: [PATCH] fixing tests --- binarycpython/tests/test_grid.py | 5 ++++- binarycpython/utils/population_extensions/dataIO.py | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/binarycpython/tests/test_grid.py b/binarycpython/tests/test_grid.py index a3bee3a6b..352f89e7a 100644 --- a/binarycpython/tests/test_grid.py +++ b/binarycpython/tests/test_grid.py @@ -27,6 +27,7 @@ TODO: Before running the non-unit tests to cover functions like evolve, we need import os import sys import json +import gzip import unittest from binarycpython.utils.functions import ( @@ -343,7 +344,9 @@ class test_export_all_info(unittest.TestCase): # datadir settings_filename = test_pop.export_all_info(use_datadir=True) self.assertTrue(os.path.isfile(settings_filename)) - with open(settings_filename, "r") as f: + + # We currently export the file as a gzip file so we need to take that into accoutn + with gzip.open(settings_filename, "rb") as f: all_info = json.loads(f.read()) # diff --git a/binarycpython/utils/population_extensions/dataIO.py b/binarycpython/utils/population_extensions/dataIO.py index 716e36ef9..bd1da06bc 100644 --- a/binarycpython/utils/population_extensions/dataIO.py +++ b/binarycpython/utils/population_extensions/dataIO.py @@ -666,14 +666,16 @@ class dataIO: def NFS_flush_hack(self, filename): """ Use opendir()/closedir() to flush NFS access to a file. + NOTE: this may or may not work! TODO: This function leads to a complaint about unclosed scandir operators. Check if that can be resolved. """ os.sync() dirname = os.path.dirname(filename) - os.scandir(dirname) - os.scandir.close() + + for _ in os.scandir(dirname): + pass def compression_type(self, filename): """ -- GitLab