diff --git a/python/nistoar/pdr/utils.py b/python/nistoar/pdr/utils.py index f99f1a1df..287fdb6ad 100644 --- a/python/nistoar/pdr/utils.py +++ b/python/nistoar/pdr/utils.py @@ -161,6 +161,7 @@ def __enter__(self): return self.open() def __exit__(self, e1, e2, e3): + self.close() return False def __del__(self): diff --git a/python/tests/nistoar/pdr/test_utils.py b/python/tests/nistoar/pdr/test_utils.py index 14d45fd7e..b8034b911 100644 --- a/python/tests/nistoar/pdr/test_utils.py +++ b/python/tests/nistoar/pdr/test_utils.py @@ -150,10 +150,14 @@ def run(self): self.f('o') def lockedop(self, who, mode='r', sleep=0.5): - with utils.LockedFile(self.lfile, mode) as lockdfile: + lf = utils.LockedFile(self.lfile, mode) + self.assertIsNone(lf.fo) + with lf as lockdfile: + self.assertIsNotNone(lf.fo) self.rfd.write(who+'a') time.sleep(sleep) self.rfd.write(who+'r') + self.assertIsNone(lf.fo) def setUp(self): self.tf = Tempfiles()