[Patches] [ python-Patches-1019220 ] Multi-line strings and unittest

SourceForge.net noreply at sourceforge.net
Tue Sep 7 07:08:14 CEST 2004


Patches item #1019220, was opened at 2004-08-30 12:00
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1019220&group_id=5470

Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Felix Wiemann (felixwiemann)
>Assigned to: Steve Purcell (purcell)
Summary: Multi-line strings and unittest

Initial Comment:
Currently, the output of unittest.py looks like this:


F
======================================================================
FAIL: test_newline (__main__.NewlineTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "unittestnewline.py", line 7, in test_newline
    self.assertEqual('foo\nbar\nbaz', 'foo\nbaz\nbaz')
AssertionError: 'foo\nbar\nbaz' != 'foo\nbaz\nbaz'

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

FAILED (failures=1)


For long strings to be compared, an output like
'foo\nbar\nbaz' != 'foo\nbaz\nbaz'
isn't particularly useful.

The attached patch makes it look like this for
multi-line strings:


F
======================================================================
FAIL: test_newline (__main__.NewlineTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "unittestnewline.py", line 7, in test_newline
    self.assertEqual('foo\nbar\nbaz', 'foo\nbaz\nbaz')
AssertionError: '''foo
bar
baz''' != '''foo
baz
baz'''

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

FAILED (failures=1)



The behavior is only changed for strings which contain
newline characters.

I admittedly do not know if there is a problem when
using the patched unittest.py on Windows (due to the
different newline convention).

----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2004-09-07 00:08

Message:
Logged In: YES 
user_id=80475

Steve, would you rule on this one?

I personally do not find it to be an improvement.

Walter Dörwald is also a heavy unittester and may have a
helpful viewpoint.



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1019220&group_id=5470


More information about the Patches mailing list