Gentoo Archives: gentoo-commits

From: "Jesus Rivero (neurogeek)" <neurogeek@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-python/amqplib/files: amqplib-1.0.2-unicode_tests_py3.patch
Date: Fri, 02 Mar 2012 22:15:28
Message-Id: 20120302221519.458AD2004B@flycatcher.gentoo.org
1 neurogeek 12/03/02 22:15:19
2
3 Added: amqplib-1.0.2-unicode_tests_py3.patch
4 Log:
5 Added Python3 support and some patches to the tests
6
7 (Portage version: 2.2.0_alpha89/cvs/Linux i686)
8
9 Revision Changes Path
10 1.1 dev-python/amqplib/files/amqplib-1.0.2-unicode_tests_py3.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/amqplib/files/amqplib-1.0.2-unicode_tests_py3.patch?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/amqplib/files/amqplib-1.0.2-unicode_tests_py3.patch?rev=1.1&content-type=text/plain
14
15 Index: amqplib-1.0.2-unicode_tests_py3.patch
16 ===================================================================
17 --- a/tests/client_0_8/test_serialization.py 2011-07-18 00:11:48.000000000 -0400
18 +++ b/tests/client_0_8/test_serialization.py 2012-03-02 16:54:35.000000000 -0500
19 @@ -32,6 +32,18 @@
20 # Python 2.5 and lower
21 bytes = str
22
23 +#Unicode Strings for py3 tests
24 +uni_strings = {
25 + 'u0100' : '\u0100',
26 + 'hello' : 'hello',
27 + 'a' : 'a',
28 + 'another' : 'And something in unicode'
29 +}
30 +
31 +if hasattr(str, 'decode'):
32 + for wk, wv in uni_strings.iteritems():
33 + uni_strings[wk] = wv.decode("utf-8")
34 +
35 import settings
36
37 from amqplib.client_0_8.serialization import AMQPReader, AMQPWriter, GenericContent
38 @@ -232,12 +244,12 @@
39
40 def test_shortstr_unicode(self):
41 w = AMQPWriter()
42 - w.write_shortstr(u'hello')
43 + w.write_shortstr(uni_strings['hello'])
44 s = w.getvalue()
45 self.assertEqualBinary(s, '\x05hello')
46
47 r = AMQPReader(s)
48 - self.assertEqual(r.read_shortstr(), u'hello')
49 + self.assertEqual(r.read_shortstr(),uni_strings['hello'])
50
51 def test_long_shortstr(self):
52 w = AMQPWriter()
53 @@ -245,7 +257,7 @@
54
55 def test_long_shortstr_unicode(self):
56 w = AMQPWriter()
57 - self.assertRaises(ValueError, w.write_shortstr, u'\u0100' * 128)
58 + self.assertRaises(ValueError, w.write_shortstr, uni_strings['u0100'] * 128)
59
60
61 #
62 @@ -273,7 +285,7 @@
63 self.assertEqual(r.read_longstr(), str(val))
64
65 def test_longstr_unicode(self):
66 - val = u'a' * 512
67 + val = uni_strings['a'] * 512
68 w = AMQPWriter()
69 w.write_longstr(val)
70 s = w.getvalue()
71 @@ -324,7 +336,7 @@
72 'foo': 7,
73 'bar': Decimal('123345.1234'),
74 'baz': 'this is some random string I typed',
75 - 'ubaz': u'And something in unicode',
76 + 'ubaz': uni_strings['another'],
77 'dday_aniv': datetime(1994, 6, 6),
78 'more': {
79 'abc': -123,