marcotcr / checklist

Beyond Accuracy: Behavioral Testing of NLP models with CheckList
MIT License
2.01k stars 204 forks source link

add with clause to load_test() #75

Closed ramji-c closed 3 years ago

ramji-c commented 3 years ago

load_test() doesn't have a file close operation when loading a test suite from file, which raises this warning

/Users/rchandrasekara/repos/checklist/checklist/abstract_test.py:12: ResourceWarning: unclosed file <_io.BufferedReader name='guardrail/behavioral_test/serialized/trial'>
  return dill.load(open(file, 'rb'))
ResourceWarning: Enable tracemalloc to get the object allocation traceback

So, I have wrapped the dill.load() line inside a with clause to safely close the file after opening.