Elena Oat added the comment:

The issue is not related only to the caret. In fact, as seen in the below 
output, the issue occurs anytime there's a newline character in the beginning 
or middle of the string to be compared. 

In short, if a newline is present in the string and it's in the beginning or 
middle, a newline character should be put at the end of the string, too. This 
will make the output look sensible. If, however, the newline is not present at 
the end, the output is not really readable (the new line is missing).

As we (me and Manvi B.) understand, the caret appears in the output only when 
the strings are similar enough, i.e. their similarity ratio is high enough. 
Otherwise, compare function doesn't show the carets in places of difference. 
This can also be seen in test case test_trailingnewline_2.

This issue occurs, probably, due to using splitlines method.

FFFFFFFF
======================================================================
FAIL: test_notrailingnewline_0 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 8, in test_notrailingnewline_0
    self.assertEqual("abcDefehiJkl", "abcdefGhijkl")
AssertionError: 'abcDefehiJkl' != 'abcdefGhijkl'
- abcDefehiJkl
?    ^  ^  ^
+ abcdefGhijkl
?    ^  ^  ^


======================================================================
FAIL: test_notrailingnewline_1 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 14, in test_notrailingnewline_1
    self.assertEqual("a\nbcdf", "a\nbddf")
AssertionError: 'a\nbcdf' != 'a\nbddf'
  a
- bcdf?  ^
+ bddf?  ^


======================================================================
FAIL: test_notrailingnewline_2 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 18, in test_notrailingnewline_2
    self.assertEqual("a\nbcdf", "a\nbddg")
AssertionError: 'a\nbcdf' != 'a\nbddg'
  a
- bcdf+ bddg

======================================================================
FAIL: test_starting_and_ending_newline_0 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 12, in test_starting_and_ending_newline_0
    self.assertEqual("\nabcDefehiJkl\n", "\nabcdefGhijkl\n")
AssertionError: '\nabcDefehiJkl\n' != '\nabcdefGhijkl\n'
  
- abcDefehiJkl
?    ^  ^  ^
+ abcdefGhijkl
?    ^  ^  ^


======================================================================
FAIL: test_startingnewline_0 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 10, in test_startingnewline_0
    self.assertEqual("\nabcDefehiJkl", "\nabcdefGhijkl")
AssertionError: '\nabcDefehiJkl' != '\nabcdefGhijkl'
  
- abcDefehiJkl?    ^  ^  ^
+ abcdefGhijkl?    ^  ^  ^


======================================================================
FAIL: test_trailingnewline_0 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 6, in test_trailingnewline_0
    self.assertEqual("abcDefehiJkl\n", "abcdefGhijkl\n")
AssertionError: 'abcDefehiJkl\n' != 'abcdefGhijkl\n'
- abcDefehiJkl
?    ^  ^  ^
+ abcdefGhijkl
?    ^  ^  ^


======================================================================
FAIL: test_trailingnewline_1 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 16, in test_trailingnewline_1
    self.assertEqual("a\nbcdf\n", "a\nbddf\n")
AssertionError: 'a\nbcdf\n' != 'a\nbddf\n'
  a
- bcdf
?  ^
+ bddf
?  ^


======================================================================
FAIL: test_trailingnewline_2 (__main__.AssertEqualTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test.py", line 20, in test_trailingnewline_2
    self.assertEqual("a\nbcdf\n", "a\nbddg\n")
AssertionError: 'a\nbcdf\n' != 'a\nbddg\n'
  a
- bcdf
+ bddg


----------------------------------------------------------------------
Ran 8 tests in 0.007s

FAILED (failures=8)

----------
nosy: +Elena.Oat
Added file: http://bugs.python.org/file41639/test2.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24780>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to