/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/test_knit.py

  • Committer: Martin
  • Date: 2017-05-21 18:16:32 UTC
  • mto: (6621.2.22 py3)
  • mto: This revision was merged to the branch mainline in revision 6624.
  • Revision ID: gzlist@googlemail.com-20170521181632-kll0wqnsq8pipfpj
Use BytesIO or StringIO from bzrlib.sixish

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for Knit data structure"""
18
18
 
19
 
from cStringIO import StringIO
20
19
import gzip
21
20
import sys
22
21
 
50
49
    knitpack_repo,
51
50
    pack_repo,
52
51
    )
 
52
from bzrlib.sixish import (
 
53
    BytesIO,
 
54
    )
53
55
from bzrlib.tests import (
54
56
    TestCase,
55
57
    TestCaseWithMemoryTransport,
246
248
        if self.file_lines is None:
247
249
            raise NoSuchFile(filename)
248
250
        else:
249
 
            return StringIO("\n".join(self.file_lines))
 
251
            return BytesIO(b"\n".join(self.file_lines))
250
252
 
251
253
    def readv(self, relpath, offsets):
252
254
        fp = self.get(relpath)
728
730
class LowLevelKnitDataTests(TestCase):
729
731
 
730
732
    def create_gz_content(self, text):
731
 
        sio = StringIO()
 
733
        sio = BytesIO()
732
734
        gz_file = gzip.GzipFile(mode='wb', fileobj=sio)
733
735
        gz_file.write(text)
734
736
        gz_file.close()
901
903
        index = self.get_knit_index(transport, "filename", "w")
902
904
        index.keys()
903
905
        call = transport.calls.pop(0)
904
 
        # call[1][1] is a StringIO - we can't test it by simple equality.
 
906
        # call[1][1] is a BytesIO - we can't test it by simple equality.
905
907
        self.assertEqual('put_file_non_atomic', call[0])
906
908
        self.assertEqual('filename.kndx', call[1][0])
907
909
        # With no history, _KndxIndex writes a new index:
989
991
        index.add_records([
990
992
            ((utf8_revision_id,), ["option"], ((utf8_revision_id,), 0, 1), [])])
991
993
        call = transport.calls.pop(0)
992
 
        # call[1][1] is a StringIO - we can't test it by simple equality.
 
994
        # call[1][1] is a BytesIO - we can't test it by simple equality.
993
995
        self.assertEqual('put_file_non_atomic', call[0])
994
996
        self.assertEqual('filename.kndx', call[1][0])
995
997
        # With no history, _KndxIndex writes a new index:
1008
1010
        index.add_records([
1009
1011
            (("version",), ["option"], (("version",), 0, 1), [(utf8_revision_id,)])])
1010
1012
        call = transport.calls.pop(0)
1011
 
        # call[1][1] is a StringIO - we can't test it by simple equality.
 
1013
        # call[1][1] is a BytesIO - we can't test it by simple equality.
1012
1014
        self.assertEqual('put_file_non_atomic', call[0])
1013
1015
        self.assertEqual('filename.kndx', call[1][0])
1014
1016
        # With no history, _KndxIndex writes a new index:
1062
1064
 
1063
1065
        self.add_a_b(index)
1064
1066
        call = transport.calls.pop(0)
1065
 
        # call[1][1] is a StringIO - we can't test it by simple equality.
 
1067
        # call[1][1] is a BytesIO - we can't test it by simple equality.
1066
1068
        self.assertEqual('put_file_non_atomic', call[0])
1067
1069
        self.assertEqual('filename.kndx', call[1][0])
1068
1070
        # With no history, _KndxIndex writes a new index:
1102
1104
        self.assertEqual(_KndxIndex.HEADER, call[1][1].getvalue())
1103
1105
        self.assertEqual({'create_parent_dir': True}, call[2])
1104
1106
        call = transport.calls.pop(0)
1105
 
        # call[1][1] is a StringIO - we can't test it by simple equality.
 
1107
        # call[1][1] is a BytesIO - we can't test it by simple equality.
1106
1108
        self.assertEqual('put_file_non_atomic', call[0])
1107
1109
        self.assertEqual('filename.kndx', call[1][0])
1108
1110
        # With no history, _KndxIndex writes a new index: