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.

Author vstinner
Recipients Ankur.Ankan, Chris AtLee, Elena.Oat, Eric Lafontaine, Jacek.Bzdak, Puneeth.Chaganti, ankurankan, ezio.melotti, gregory.p.smith, levkivskyi, michael.foord, nnja, paul.moore, pitrou, rbcollins, serhiy.storchaka, steve.dower, tim.golden, vstinner, zach.ware
Date 2017-02-08.08:36:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1486543007.08.0.0781818131557.issue19217@psf.upfronthosting.co.za>
In-reply-to
Content
unittest_unified_diff.patch: Rebased patch for the default branch. My patch updates also unit tests.

The patch changes the test output. If we decide to apply the patch, I propose to only apply it to the default branch (Python 3.7).

The bug report is about a test which fails. I'm not sure that it's a real blocker issue that Python is slow when a test fails. At least, it should be fast when a test pass. I mean that I like the current output, I'm not sure about the new output.

Example with attached unified_diff.py.

Before:
@@@@@@@@@@@@@@@@@
F
======================================================================
FAIL: test_x (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "unified_diff.py", line 5, in test_x
    self.assertEqual([], [None])
AssertionError: Lists differ: [] != [None]

Second list contains 1 additional elements.
First extra element 0:
None

- []
+ [None]

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (failures=1)
@@@@@@@@@@@@@@@@@

With the patch:
@@@@@@@@@@@@@@@@@
haypo@selma$ ./python unified_diff.py 
F
======================================================================
FAIL: test_x (__main__.Test)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "unified_diff.py", line 5, in test_x
    self.assertEqual([], [None])
AssertionError: Lists differ: [] != [None]

Second list contains 1 additional elements.
First extra element 0:
None

--- 
+++ 
@@ -1 +1 @@
-[]
+[None]

----------------------------------------------------------------------
Ran 1 test in 0.001s

FAILED (failures=1)
@@@@@@@@@@@@@@@@@


The patch adds the following header which can be suprising:
@@@@@@@@@@@@@@@@@
--- 
+++ 
@@ -1 +1 @@
@@@@@@@@@@@@@@@@@


Maybe we should pass a "file name" to unified_diff() to get something like:
@@@@@@@@@@@@@@@@@
--- expected
+++ got
@@ -1 +1 @@
@@@@@@@@@@@@@@@@@
History
Date User Action Args
2017-02-08 08:36:47vstinnersetrecipients: + vstinner, gregory.p.smith, paul.moore, pitrou, rbcollins, tim.golden, ezio.melotti, michael.foord, zach.ware, serhiy.storchaka, Jacek.Bzdak, steve.dower, Ankur.Ankan, Elena.Oat, nnja, ankurankan, Puneeth.Chaganti, levkivskyi, Chris AtLee, Eric Lafontaine
2017-02-08 08:36:47vstinnersetmessageid: <1486543007.08.0.0781818131557.issue19217@psf.upfronthosting.co.za>
2017-02-08 08:36:47vstinnerlinkissue19217 messages
2017-02-08 08:36:46vstinnercreate