1 # Copyright 2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
9 from portage import _unicode_decode
10 from portage import _unicode_encode
11 from portage.tests import TestCase
13 class ArrayFromfileEofTestCase(TestCase):
15 def testArrayFromfileEof(self):
16 # This tests if the following python issue is fixed
17 # in the currently running version of python:
18 # http://bugs.python.org/issue5334
20 input_data = "an arbitrary string"
21 input_bytes = _unicode_encode(input_data,
22 encoding='utf_8', errors='strict')
23 f = tempfile.TemporaryFile()
32 a.fromfile(f, len(input_bytes) + 1)
34 # python-3.0 lost data here
40 data.append(_unicode_decode(a.tostring(),
41 encoding='utf_8', errors='strict'))
45 self.assertEqual(input_data, ''.join(data))