Skip to content

Commit

Permalink
Improved file entry test coverage (#334)
Browse files Browse the repository at this point in the history
* Improved file entry test coverage
  • Loading branch information
joachimmetz authored and Onager committed Nov 23, 2018
1 parent 236a321 commit 56c1bee
Show file tree
Hide file tree
Showing 3 changed files with 291 additions and 50 deletions.
13 changes: 9 additions & 4 deletions dfvfs/vfs/file_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,15 @@ def __init__(

def __del__(self):
"""Cleans up the file entry."""
# __del__ can be invoked before __init__ has completed.
if hasattr(self, '_file_system'):
self._file_system.Close()
self._file_system = None
# Note that __del__ can be invoked before __init__ has completed.

# Make a local copy of file_system in case the attribute is set to None
# after the check and before the call to Close.
file_system = getattr(self, '_file_system', None)
if file_system:
file_system.Close()

self._file_system = None

def _GetAttributes(self):
"""Retrieves the attributes.
Expand Down
2 changes: 2 additions & 0 deletions dfvfs/vfs/file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class FileSystem(object):
"""Virtual file system interface."""

# Note that redundant-returns-doc is broken for pylint 1.7.x for abstract
# methods
# pylint: disable=redundant-returns-doc

LOCATION_ROOT = '/'
Expand Down
Loading

0 comments on commit 56c1bee

Please sign in to comment.