Track call_count in MockOpen

This commit is contained in:
Erik Johnson 2018-06-17 23:54:42 -05:00
parent 2598d2453a
commit fc0aa9934f
No known key found for this signature in database
GPG key ID: 5E5583C437808F3F

View file

@ -316,12 +316,14 @@ class MockOpen(object):
self.read_data = read_data
self.filehandles = {}
self.call_count = 0
def __call__(self, name, *args, **kwargs):
'''
Match the file being opened to the patterns in the read_data and spawn
a mocked filehandle with the corresponding file contents.
'''
self.call_count += 1
for pat in self.read_data:
if pat == '*':
continue