A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-July/081276.html below:

[Python-Dev] Unittest PEP do's and don'ts (BDFL pronouncement)

[Python-Dev] Unittest PEP do's and don'ts (BDFL pronouncement)Georg Brandl g.brandl at gmx.net
Wed Jul 16 23:46:46 CEST 2008
C. Titus Brown schrieb:

> Sorry for the second message, but... let's compare:
> 
> test_sort.py:
>  #! /usr/bin/env python
>  import unittest
>  class Test(unittest.TestCase):
>   def test_me(self):
>      seq = [ 5, 4, 1, 3, 2 ]
>      seq.sort()
>      self.assertEqual(seq, [1, 2, 3, 4, 5])
> 
>  if __name__ == '__main__':
>     unittest.main()
> 
> with
> 
> test_sort2.py :
> 
>  def test_me():
>     seq = [ 5, 4, 1, 3 2 ]
>     seq.sort()
>     assert seq == [1, 2, 3, 4, 5]
> 
> The *only value* that unittest adds here is in the 'assertEqual'
> statement, which (I think) returns a richer error message than 'assert'.

If you use py.test, it does some magic to find out your test is an
equality comparison and displays both operands' repr().  Don't know about
nose.

Georg

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4