[docs] Improve unittest basic example in the doc (issue 11468)
zachary.ware at gmail.com
zachary.ware at gmail.com
Tue May 27 19:15:24 CEST 2014
http://bugs.python.org/review/11468/diff/2986/Doc/library/unittest.rst
File Doc/library/unittest.rst (right):
http://bugs.python.org/review/11468/diff/2986/Doc/library/unittest.rst#newcode131
Doc/library/unittest.rst:131: self.assertEqual(s.split(), ['hello',
'world'])
On 2014/05/27 14:57:56, berkerpeksag wrote:
> I think this is a good example to use assertListEqual.
There should be no need to use assertListEqual explicitly, assertEqual
uses the type-specific equality functions under the hood:
>>> unittest.TestCase().assertEqual('hello world'.split(), ['goodbye',
'world'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "P:\Python34\lib\unittest\case.py", line 797, in assertEqual
assertion_func(first, second, msg=msg)
File "P:\Python34\lib\unittest\case.py", line 995, in assertListEqual
self.assertSequenceEqual(list1, list2, msg, seq_type=list)
File "P:\Python34\lib\unittest\case.py", line 977, in
assertSequenceEqual
self.fail(msg)
File "P:\Python34\lib\unittest\case.py", line 642, in fail
raise self.failureException(msg)
AssertionError: Lists differ: ['hello', 'world'] != ['goodbye', 'world']
First differing element 0:
hello
goodbye
- ['hello', 'world']
+ ['goodbye', 'world']
http://bugs.python.org/review/11468/
More information about the docs
mailing list