Rev 6593: (vila) Fix python-2.7.6 test failures. (Vincent Ladeuil) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Apr 9 13:36:25 UTC 2014
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6593 [merge]
revision-id: pqm at pqm.ubuntu.com-20140409133625-s24spv3kha2w2860
parent: pqm at pqm.ubuntu.com-20140403074532-0sdwrky6ie4y20l4
parent: v.ladeuil+lp at free.fr-20140409080523-kb5kr12j29imskd0
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2014-04-09 13:36:25 +0000
message:
(vila) Fix python-2.7.6 test failures. (Vincent Ladeuil)
modified:
bzrlib/email_message.py email_message.py-20070718143823-660zfcl54xi1v65u-1
bzrlib/tests/test_email_message.py test_email_message.p-20070718143823-660zfcl54xi1v65u-2
bzrlib/tests/test_osutils.py test_osutils.py-20051201224856-e48ee24c12182989
doc/en/release-notes/bzr-2.7.txt bzr2.7.txt-20130727124539-wnx897hy9l2h9f7x-1
=== modified file 'bzrlib/email_message.py'
--- a/bzrlib/email_message.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/email_message.py 2014-04-09 08:00:39 +0000
@@ -149,7 +149,7 @@
@staticmethod
def send(config, from_address, to_address, subject, body, attachment=None,
- attachment_filename=None, attachment_mime_subtype='plain'):
+ attachment_filename=None, attachment_mime_subtype='plain'):
"""Create an email message and send it with SMTPConnection.
:param config: config object to pass to SMTPConnection constructor.
=== modified file 'bzrlib/tests/test_email_message.py'
--- a/bzrlib/tests/test_email_message.py 2011-12-16 19:18:39 +0000
+++ b/bzrlib/tests/test_email_message.py 2014-04-09 08:00:39 +0000
@@ -14,13 +14,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+import sys
from email.Header import decode_header
from bzrlib import __version__ as _bzrlib_version
from bzrlib.email_message import EmailMessage
from bzrlib.errors import BzrBadParameterNotUnicode
from bzrlib.smtp_connection import SMTPConnection
-from bzrlib.tests import TestCase
+from bzrlib import tests
EMPTY_MESSAGE = '''\
From: from at from.com
@@ -65,9 +66,22 @@
body
''' % { 'version': _bzrlib_version, 'boundary': BOUNDARY }
-SIMPLE_MULTIPART_MESSAGE = _MULTIPART_HEAD + '--%s--' % BOUNDARY
-
-COMPLEX_MULTIPART_MESSAGE = _MULTIPART_HEAD + '''\
+
+def final_newline_or_not(msg):
+ if sys.version_info >= (2, 7, 6):
+ # Some internals of python's email module changed in an (minor)
+ # incompatible way: a final newline is appended in 2.7.6...
+ msg += '\n'
+ return msg
+
+
+def simple_multipart_message():
+ msg = _MULTIPART_HEAD + '--%s--' % BOUNDARY
+ return final_newline_or_not(msg)
+
+
+def complex_multipart_message(typ):
+ msg = _MULTIPART_HEAD + '''\
--%(boundary)s
MIME-Version: 1.0
Content-Type: text/%%s; charset="us-ascii"; name="lines.txt"
@@ -81,9 +95,11 @@
e
--%(boundary)s--''' % { 'boundary': BOUNDARY }
-
-
-class TestEmailMessage(TestCase):
+ msg = final_newline_or_not(msg)
+ return msg % (typ,)
+
+
+class TestEmailMessage(tests.TestCase):
def test_empty_message(self):
msg = EmailMessage('from at from.com', 'to at to.com', 'subject')
@@ -100,15 +116,18 @@
msg = EmailMessage('from at from.com', 'to at to.com', 'subject', body)
self.assertEqualDiff(expected, msg.as_string())
- def test_multipart_message(self):
+ def test_multipart_message_simple(self):
msg = EmailMessage('from at from.com', 'to at to.com', 'subject')
msg.add_inline_attachment('body')
- self.assertEqualDiff(SIMPLE_MULTIPART_MESSAGE, msg.as_string(BOUNDARY))
-
+ self.assertEqualDiff(simple_multipart_message(),
+ msg.as_string(BOUNDARY))
+
+
+ def test_multipart_message_complex(self):
msg = EmailMessage('from at from.com', 'to at to.com', 'subject', 'body')
msg.add_inline_attachment(u'a\nb\nc\nd\ne\n', 'lines.txt', 'x-subtype')
- self.assertEqualDiff(COMPLEX_MULTIPART_MESSAGE % 'x-subtype',
- msg.as_string(BOUNDARY))
+ self.assertEqualDiff(complex_multipart_message('x-subtype'),
+ msg.as_string(BOUNDARY))
def test_headers_accept_unicode_and_utf8(self):
for user in [ u'Pepe P\xe9rez <pperez at ejemplo.com>',
@@ -148,40 +167,6 @@
self.assertEqual('to2 at to.com', msg['To'])
self.assertEqual('cc at cc.com', msg['Cc'])
- def test_send(self):
- class FakeConfig:
- def get(self, option):
- return None
-
- messages = []
-
- def send_as_append(_self, msg):
- messages.append(msg.as_string(BOUNDARY))
-
- old_send_email = SMTPConnection.send_email
- try:
- SMTPConnection.send_email = send_as_append
-
- EmailMessage.send(FakeConfig(), 'from at from.com', 'to at to.com',
- 'subject', 'body', u'a\nb\nc\nd\ne\n', 'lines.txt')
- self.assertEqualDiff(COMPLEX_MULTIPART_MESSAGE % 'plain',
- messages[0])
- messages[:] = []
-
- EmailMessage.send(FakeConfig(), 'from at from.com', 'to at to.com',
- 'subject', 'body', u'a\nb\nc\nd\ne\n', 'lines.txt',
- 'x-patch')
- self.assertEqualDiff(COMPLEX_MULTIPART_MESSAGE % 'x-patch',
- messages[0])
- messages[:] = []
-
- EmailMessage.send(FakeConfig(), 'from at from.com', 'to at to.com',
- 'subject', 'body')
- self.assertEqualDiff(SIMPLE_MESSAGE_ASCII , messages[0])
- messages[:] = []
- finally:
- SMTPConnection.send_email = old_send_email
-
def test_address_to_encoded_header(self):
def decode(s):
"""Convert a RFC2047-encoded string to a unicode string."""
@@ -224,3 +209,46 @@
}
for string_, pair in pairs.items():
self.assertEqual(pair, EmailMessage.string_with_encoding(string_))
+
+
+class TestSend(tests.TestCase):
+
+ def setUp(self):
+ super(TestSend, self).setUp()
+ self.messages = []
+
+ def send_as_append(_self, msg):
+ self.messages.append(msg.as_string(BOUNDARY))
+
+ self.overrideAttr(SMTPConnection, 'send_email', send_as_append)
+
+
+
+ def send_email(self, attachment=None, attachment_filename=None,
+ attachment_mime_subtype='plain'):
+ class FakeConfig:
+ def get(self, option):
+ return None
+
+ EmailMessage.send(FakeConfig(), 'from at from.com', 'to at to.com',
+ 'subject', 'body',
+ attachment=attachment,
+ attachment_filename=attachment_filename,
+ attachment_mime_subtype=attachment_mime_subtype)
+
+ def assertMessage(self, expected):
+ self.assertLength(1, self.messages)
+ self.assertEqualDiff(expected, self.messages[0])
+
+ def test_send_plain(self):
+ self.send_email(u'a\nb\nc\nd\ne\n', 'lines.txt')
+ self.assertMessage(complex_multipart_message('plain'))
+
+ def test_send_patch(self):
+ self.send_email(u'a\nb\nc\nd\ne\n', 'lines.txt', 'x-patch')
+ self.assertMessage(complex_multipart_message('x-patch'))
+
+ def test_send_simple(self):
+ self.send_email()
+ self.assertMessage(SIMPLE_MESSAGE_ASCII)
+
=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py 2013-06-24 12:03:12 +0000
+++ b/bzrlib/tests/test_osutils.py 2014-04-09 08:05:23 +0000
@@ -943,9 +943,15 @@
osutils._win32_pathjoin('path/to', 'C:/foo'))
self.assertEqual('path/to/foo',
osutils._win32_pathjoin('path/to/', 'foo'))
- self.assertEqual('/foo',
+
+ def test_pathjoin_late_bugfix(self):
+ if sys.version_info < (2, 7, 6):
+ expected = '/foo'
+ else:
+ expected = 'C:/foo'
+ self.assertEqual(expected,
osutils._win32_pathjoin('C:/path/to/', '/foo'))
- self.assertEqual('/foo',
+ self.assertEqual(expected,
osutils._win32_pathjoin('C:\\path\\to\\', '\\foo'))
def test_normpath(self):
=== modified file 'doc/en/release-notes/bzr-2.7.txt'
--- a/doc/en/release-notes/bzr-2.7.txt 2014-04-02 16:15:32 +0000
+++ b/doc/en/release-notes/bzr-2.7.txt 2014-04-09 08:05:23 +0000
@@ -63,6 +63,12 @@
suite. This can include new facilities for writing tests, fixes to
spurious test failures and changes to the way things should be tested.
+* Handle (minor) incompatible change in python 2.7.6 leading to test
+ failures. Only tests are affected. (Vincent Ladeuil, #1303879)
+
+* Take python 2.7.6 late (better than never) bugfix in ntpath.py into
+ account. Only tests are affected (Vincent Ladeuil, #1303879).
+
* Remove wrong assumption about how TCP server and client interact when run
inside the same process. (Vincent Ladeuil, #1269886).
More information about the bazaar-commits
mailing list