diff options
author | Thiago da Silva <thiago@redhat.com> | 2014-03-21 16:02:36 -0400 |
---|---|---|
committer | Luis Pabon <lpabon@redhat.com> | 2014-03-26 13:30:22 -0700 |
commit | 09688dc594e9d82ba3a85b55fa569ccd2bb0b0df (patch) | |
tree | e07193b75a23b7c32c0d46961bfdcbbac2b00d01 /test | |
parent | 972c252c41e516e7ce54406ac79b0a35adb88bca (diff) |
fix __exit__ function not closing file descriptor
The file descriptor is not being closed because
it is self._fd is None
Change-Id: I7edc8a78b09bdd76d59ac8f3dbc809af652f9b0e
Signed-off-by: Thiago da Silva <thiago@redhat.com>
Reviewed-on: http://review.gluster.org/7315
Reviewed-by: Luis Pabon <lpabon@redhat.com>
Tested-by: Luis Pabon <lpabon@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/obj/test_diskfile.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index 64fa6e7..f8c26db 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -204,6 +204,16 @@ class TestDiskFile(unittest.TestCase): self.assertRaises(DiskFileNotOpen, gdf.reader) self.assertRaises(DiskFileNotOpen, gdf.__enter__) + def test_open_and_close(self): + mock_close = Mock() + + with mock.patch("gluster.swift.obj.diskfile.do_close", mock_close): + gdf = self._create_and_get_diskfile("vol0", "p57", "ufo47", + "bar", "z") + with gdf.open(): + assert gdf._fd is not None + self.assertTrue(mock_close.called) + def test_open_existing_metadata(self): the_path = os.path.join(self.td, "vol0", "bar") the_file = os.path.join(the_path, "z") |