/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 bzrlib/tests/file_utils.py

  • Committer: Robert Collins
  • Date: 2010-05-05 00:05:29 UTC
  • mto: This revision was merged to the branch mainline in revision 5206.
  • Revision ID: robertc@robertcollins.net-20100505000529-ltmllyms5watqj5u
Make 'pydoc bzrlib.tests.build_tree_shape' useful.

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