~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_textfile.py

  • Committer: Aaron Bentley
  • Date: 2006-04-15 00:17:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1673.
  • Revision ID: aaron.bentley@utoronto.ca-20060415001738-09feeab6b5ee61d1
Add text_file function

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from StringIO import StringIO
 
2
 
 
3
from bzrlib.errors import BinaryFile
 
4
from bzrlib.tests import TestCase
 
5
from bzrlib.textfile import text_file
 
6
 
 
7
 
 
8
class TextFile(TestCase):
 
9
    def test_text_file(self):
 
10
        s = StringIO('ab' * 2048)
 
11
        s.seek(0)
 
12
        self.assertEqual(text_file(s).read(), s.getvalue())
 
13
        s = StringIO('a' * 1023 + '\x00')
 
14
        self.assertRaises(BinaryFile, text_file, s)
 
15
        s = StringIO('a' * 1024 + '\x00')
 
16
        self.assertEqual(text_file(s).read(), s.getvalue())
 
17