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

  • Committer: Jelmer Vernooij
  • Date: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

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 io import BytesIO
17
18
 
18
19
from ..errors import BinaryFile
19
 
from ..sixish import (
20
 
    BytesIO,
21
 
    )
22
20
from . import TestCase, TestCaseInTempDir
23
21
from ..textfile import text_file, check_text_lines, check_text_path
24
22
 
34
32
        self.assertEqual(text_file(s).read(), s.getvalue())
35
33
 
36
34
    def test_check_text_lines(self):
37
 
        lines = ['ab' * 2048]
 
35
        lines = [b'ab' * 2048]
38
36
        check_text_lines(lines)
39
 
        lines = ['a' * 1023 + '\x00']
 
37
        lines = [b'a' * 1023 + b'\x00']
40
38
        self.assertRaises(BinaryFile, check_text_lines, lines)
41
39
 
42
40
 
43
41
class TextPath(TestCaseInTempDir):
44
42
 
45
43
    def test_text_file(self):
46
 
        with file('boo', 'wb') as f: f.write('ab' * 2048)
 
44
        with open('boo', 'wb') as f:
 
45
            f.write(b'ab' * 2048)
47
46
        check_text_path('boo')
48
 
        with file('boo', 'wb') as f: f.write('a' * 1023 + '\x00')
 
47
        with open('boo', 'wb') as f:
 
48
            f.write(b'a' * 1023 + b'\x00')
49
49
        self.assertRaises(BinaryFile, check_text_path, 'boo')