/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: Breezy landing bot
  • Author(s): Colin Watson
  • Date: 2020-11-16 21:47:08 UTC
  • mfrom: (7521.1.1 remove-lp-workaround)
  • Revision ID: breezy.the.bot@gmail.com-20201116214708-jos209mgxi41oy15
Remove breezy.git workaround for bazaar.launchpad.net.

Merged from https://code.launchpad.net/~cjwatson/brz/remove-lp-workaround/+merge/393710

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 io import BytesIO
 
18
 
18
19
 
19
20
class FakeReadFile(object):
20
21
    """A file-like object that can be given predefined content and read
22
23
 
23
24
    def __init__(self, data):
24
25
        """Initialize the mock file object with the provided data."""
25
 
        self.data = StringIO(data)
 
26
        self.data = BytesIO(data)
26
27
        self.max_read_size = None
27
28
        self.read_count = 0
28
29
 
30
31
        """Reads size characters from the input (or the rest of the string if
31
32
        size is -1)."""
32
33
        data = self.data.read(size)
33
 
        self.max_read_size = max(self.max_read_size, len(data))
 
34
        self.max_read_size = max(self.max_read_size or 0, len(data))
34
35
        self.read_count += 1
35
36
        return data
36
37