/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/file_utils.py

  • Committer: Jelmer Vernooij
  • Date: 2020-04-05 19:11:34 UTC
  • mto: (7490.7.16 work)
  • mto: This revision was merged to the branch mainline in revision 7501.
  • Revision ID: jelmer@jelmer.uk-20200405191134-0aebh8ikiwygxma5
Populate the .gitignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
from cStringIO import StringIO
 
17
from ..sixish import (
 
18
    BytesIO,
 
19
    )
 
20
 
18
21
 
19
22
class FakeReadFile(object):
20
23
    """A file-like object that can be given predefined content and read
22
25
 
23
26
    def __init__(self, data):
24
27
        """Initialize the mock file object with the provided data."""
25
 
        self.data = StringIO(data)
 
28
        self.data = BytesIO(data)
26
29
        self.max_read_size = None
27
30
        self.read_count = 0
28
31
 
30
33
        """Reads size characters from the input (or the rest of the string if
31
34
        size is -1)."""
32
35
        data = self.data.read(size)
33
 
        self.max_read_size = max(self.max_read_size, len(data))
 
36
        self.max_read_size = max(self.max_read_size or 0, len(data))
34
37
        self.read_count += 1
35
38
        return data
36
39