Accept content in Writer

This commit is contained in:
Bo Maryniuk 2016-06-30 15:21:49 +02:00
parent c4c2ac7e70
commit bc1a8b7e45

View File

@ -60,8 +60,11 @@ def mock_open(data=None):
class Writable(StringIO):
def __init__(self):
StringIO.__init__(self)
def __init__(self, data=None):
if data:
StringIO.__init__(self, data)
else:
StringIO.__init__(self)
self.data = []
def __exit__(self, exc_type, exc_val, exc_tb):
@ -70,9 +73,6 @@ class Writable(StringIO):
def __enter__(self):
return self
def read(self, n=-1):
return ""
def write(self, s):
self.data.append(s)