This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_email failures under desktop Windows
Type: behavior Stage: resolved
Components: email, Tests Versions: Python 3.3, Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: barry, pitrou, python-dev, r.david.murray, terry.reedy
Priority: normal Keywords: patch

Created on 2011-05-09 16:33 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
12037_test_email.diff terry.reedy, 2013-08-31 00:29 review
12037_test_email2.diff terry.reedy, 2013-08-31 02:13 review
Messages (7)
msg135606 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-05-09 16:33
The title says it all. Ideally (!), changing .hgignore should be enough to fix this issue.
(NB: I have only tested the default branch)

======================================================================
FAIL: test_byte_message_rfc822_only (test_email.TestMessageAPI)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\t\cp\lib\test\test_email\test_email.py", line 189, in test_byte_messa
ge_rfc822_only
    self.assertEqual(out.getvalue(), msgdata)
AssertionError: Lists differ: ["b'Return-Path: <sender@examp... != ["b'Return-Pa
th: <sender@examp...

First differing element 0:
b'Return-Path: <sender@example.net>\n'
b'Return-Path: <sender@example.net>\r\n'

- ["b'Return-Path: <sender@example.net>\\n'",
+ ["b'Return-Path: <sender@example.net>\\r\\n'",
?                                        +++

-  "b'Delivery-Date: Mon, 08 Feb 2010 14:05:16 +0100\\n'",
+  "b'Delivery-Date: Mon, 08 Feb 2010 14:05:16 +0100\\r\\n'",
?                                                     +++

-  "b'Received: from example.org (example.org [64.5.53.58])\\n'",
+  "b'Received: from example.org (example.org [64.5.53.58])\\r\\n'",
?                                                            +++

-  "b'    by example.net (node=mxbap2) with ESMTP (Nemesis)\\n'",
+  "b'    by example.net (node=mxbap2) with ESMTP (Nemesis)\\r\\n'",
?                                                            +++

-  "b'    id UNIQUE for someone@example.com; Mon, 08 Feb 2010 14:05:16 +0100\\n'
",
+  "b'    id UNIQUE for someone@example.com; Mon, 08 Feb 2010 14:05:16 +0100\\r\
\n'",
?                                                                             ++
+

-  "b'Date: Mon, 01 Feb 2010 12:21:16 +0100\\n'",
+  "b'Date: Mon, 01 Feb 2010 12:21:16 +0100\\r\\n'",
?                                            +++

-  'b\'From: "Sender" <sender@example.net>\\n\'',
+  'b\'From: "Sender" <sender@example.net>\\r\\n\'',
?                                           +++

-  "b'To: <someone@example.com>\\n'",
+  "b'To: <someone@example.com>\\r\\n'",
?                                +++

-  "b'Subject: GroupwiseForwardingTest\\n'",
+  "b'Subject: GroupwiseForwardingTest\\r\\n'",
?                                       +++

-  "b'Mime-Version: 1.0\\n'",
+  "b'Mime-Version: 1.0\\r\\n'",
?                      +++

-  "b'Content-Type: message/rfc822\\n'",
+  "b'Content-Type: message/rfc822\\r\\n'",
?                                   +++

-  "b'\\n'",
+  "b'\\r\\n'",
?     +++

   "b'Return-path: <sender@example.net>\\r\\n'",
   "b'Message-ID: <4B66B890.4070408@teconcept.de>\\r\\n'",
   "b'Date: Mon, 01 Feb 2010 12:18:40 +0100\\r\\n'",
   'b\'From: "Dr. Sender" <sender@example.net>\\r\\n\'',
   "b'MIME-Version: 1.0\\r\\n'",
   'b\'To: "Recipient" <recipient@example.com>\\r\\n\'',
   "b'Subject: GroupwiseForwardingTest\\r\\n'",
   "b'Content-Type: text/plain; charset=ISO-8859-15\\r\\n'",
   "b'Content-Transfer-Encoding: 7bit\\r\\n'",
   "b'\\r\\n'",
   "b'Testing email forwarding with Groupwise 1.2.2010\\r\\n'"]

======================================================================
FAIL: test_flatten_linesep_overrides_policy (test_email.TestParsers)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\t\cp\lib\test\test_email\test_email.py", line 3074, in test_flatten_l
inesep_overrides_policy
    self.assertEqual(s.getvalue(), text)
AssertionError: 'Return-Path: <aperson@dom.ain>\nReceived: by mail.dom.ain (Post
fix, from userid [truncated]... != 'Return-Path: <aperson@dom.ain>\r\nReceived:
by mail.dom.ain (Postfix, from user [truncated]...
- Return-Path: <aperson@dom.ain>
+ Return-Path: <aperson@dom.ain>
?                               +
- Received: by mail.dom.ain (Postfix, from userid 889)
+ Received: by mail.dom.ain (Postfix, from userid 889)
?                                                     +
-       id B9D0AD35DB; Tue,  4 Jun 2002 21:46:59 -0400 (EDT)
+       id B9D0AD35DB; Tue,  4 Jun 2002 21:46:59 -0400 (EDT)
?                                                           +
- Message-ID: <15613.28051.707126.569693@dom.ain>
+ Message-ID: <15613.28051.707126.569693@dom.ain>
?                                                +
- Date: Tue, 4 Jun 2002 21:46:59 -0400
+ Date: Tue, 4 Jun 2002 21:46:59 -0400
?                                     +
- MIME-Version: 1.0
+ MIME-Version: 1.0
?                  +
- Content-Type: text/plain; charset=us-ascii
+ Content-Type: text/plain; charset=us-ascii
?                                           +
- Content-Transfer-Encoding: 7bit
+ Content-Transfer-Encoding: 7bit
?                                +
- Subject: bug demonstration
+ Subject: bug demonstration
?                           +
-       123456789112345678921234567893123456789412345678951234567896123456789712
34567898112345678911234567892123456789112345678911234567892123456789
+       123456789112345678921234567893123456789412345678951234567896123456789712
34567898112345678911234567892123456789112345678911234567892123456789
?
                                                                    +
-       more text
+       more text
?                +
- From: aperson@dom.ain (Anne P. Erson)
+ From: aperson@dom.ain (Anne P. Erson)
?                                      +
- To: bperson@dom.ain (Barney P. Erson)
+ To: bperson@dom.ain (Barney P. Erson)
?                                      +
-
+
  test


----------------------------------------------------------------------
Ran 502 tests in 4.438s

FAILED (failures=3, skipped=1)
msg196604 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-08-31 00:29
Two years later, I get the exact same failure in both repository 3.3.2+ and installed 3.3.2. So eol extension and .hgignore seem irrelevant.

I sometime think Python should stop generating files with \r\n. In other words, change os.linesep to '\n' even on windows. Or maybe just do it for test files that will be read in binary mode and compared with generated data. The only program I know of that does not recognize \n alone is Notepad, and that hardly worth bothering with.

Repository 3.4.0a1+ has the same error + essentially the same in
test_as_bytes. (Repository 2.7.5+ passes.) For one test, \r only appears in the file; in the other, it also sporadically appeared in the generated bytes. I don't know why the test works on buildbots, but the attached patch fixes it for my desktop. Any objections to committing it?
msg196605 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-08-31 01:10
We have to be careful, since while Windows may no longer care about \r\n, the RFCs certainly do, and the email package is very concerned with the RFC.

However, neither of these tests are testing linesep discipline, so it is fine to fix them.  I've made review comments indicating what I think is a better fix (reading in universal newline mode and encoding the result to bytes to get the comparison bytes data in standard form).
msg196609 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-08-31 02:13
Attached patch works here too. Only the test...rfc822 part applies to 3.3, both to 3.4. The same idea works for #18889 too.
msg196614 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-08-31 03:14
Looks good to me, go ahead and push it.
msg196673 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-31 21:16
New changeset f0eedca4b2a2 by Terry Jan Reedy in branch '3.3':
Issue #12037: Fix test_email for desktop Windows.
http://hg.python.org/cpython/rev/f0eedca4b2a2
msg196674 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-08-31 21:17
New changeset 5600e9a5c35d by Terry Jan Reedy in branch 'default':
Issue #12037: Fix test_email for desktop Windows.
http://hg.python.org/cpython/rev/5600e9a5c35d
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56246
2013-08-31 21:19:05terry.reedysetstatus: open -> closed
title: test_email failures under Windows with the eol extension activated -> test_email failures under desktop Windows
resolution: fixed
stage: commit review -> resolved
2013-08-31 21:17:07python-devsetmessages: + msg196674
2013-08-31 21:16:03python-devsetnosy: + python-dev
messages: + msg196673
2013-08-31 03:14:22r.david.murraysetmessages: + msg196614
2013-08-31 02:13:15terry.reedysetfiles: + 12037_test_email2.diff

messages: + msg196609
2013-08-31 01:10:31r.david.murraysetmessages: + msg196605
2013-08-31 00:29:35terry.reedysetfiles: + 12037_test_email.diff

versions: + Python 3.4
keywords: + patch
nosy: + terry.reedy

messages: + msg196604
stage: commit review
2012-05-28 20:23:55r.david.murraysetassignee: r.david.murray ->

components: + email
nosy: + barry
2011-05-09 16:33:48pitroucreate