summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-09-25 05:58:16 +0000
committerZac Medico <zmedico@gentoo.org>2009-09-25 05:58:16 +0000
commita7104850eb59b65fcf3a5cd9f93d71c213c1b02e (patch)
tree7d5a98c876253d0644ef7d17d3df899258a1f185 /pym
parent1dd031f0a5457b9b53c7a3027b29cea9278f81ec (diff)
downloadportage-a7104850eb59b65fcf3a5cd9f93d71c213c1b02e.tar.gz
portage-a7104850eb59b65fcf3a5cd9f93d71c213c1b02e.tar.bz2
portage-a7104850eb59b65fcf3a5cd9f93d71c213c1b02e.zip
Add a test case for this issue: http://bugs.python.org/issue5334
svn path=/main/trunk/; revision=14423
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/tests/ebuild/test_array_fromfile_eof.py44
-rw-r--r--pym/portage/tests/ebuild/test_pty_eof.py2
2 files changed, 45 insertions, 1 deletions
diff --git a/pym/portage/tests/ebuild/test_array_fromfile_eof.py b/pym/portage/tests/ebuild/test_array_fromfile_eof.py
new file mode 100644
index 000000000..8eacb406b
--- /dev/null
+++ b/pym/portage/tests/ebuild/test_array_fromfile_eof.py
@@ -0,0 +1,44 @@
+# Copyright 2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+import array
+import pty
+import tempfile
+
+from portage import _unicode_decode
+from portage import _unicode_encode
+from portage.tests import TestCase
+
+class ArrayFromfileEofTestCase(TestCase):
+
+ def testArrayFromfileEof(self):
+ # This tests if the following python issue is fixed
+ # in the currently running version of python:
+ # http://bugs.python.org/issue5334
+
+ input_data = "an arbitrary string"
+ f = tempfile.TemporaryFile()
+ f.write(_unicode_encode(input_data,
+ encoding='utf_8', errors='strict'))
+
+ f.seek(0)
+ data = []
+ eof = False
+ while not eof:
+ a = array.array('B')
+ try:
+ a.fromfile(f, len(input_data) + 1)
+ except EOFError:
+ # python-3.0 lost data here
+ eof = True
+
+ if not a:
+ eof = True
+ else:
+ data.append(_unicode_decode(a.tostring(),
+ encoding='utf_8', errors='strict'))
+
+ f.close()
+
+ self.assertEqual(input_data, ''.join(data))
diff --git a/pym/portage/tests/ebuild/test_pty_eof.py b/pym/portage/tests/ebuild/test_pty_eof.py
index 8723372b1..88334bcb9 100644
--- a/pym/portage/tests/ebuild/test_pty_eof.py
+++ b/pym/portage/tests/ebuild/test_pty_eof.py
@@ -1,4 +1,4 @@
-# Copyright 1998-2007 Gentoo Foundation
+# Copyright 2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$