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/2001-February/012858.html below:

[Python-Dev] Unit testing (again)

[Python-Dev] Unit testing (again)Andrew Kuchling akuchlin@mems-exchange.org
Tue, 13 Feb 2001 12:29:35 -0500
On Tue, Feb 13, 2001 at 12:29:35AM -0500, Jeremy Hylton wrote:
>I hope it's simple disagreement and not arrogance.  I do not agree

I trust not. :) My primary concern is that the tests are quickly
readable, because they're also a form of documentation (hopefully not
the only one though).  I have enough problems debugging the actual
code without having to debug a test suite.

Consider the example Chris posted, which features the snippet:

    def testGetItemFails(self):
        self.assertRaises(KeyError, self._getitemfail)

    def _getitemfail(self):
        return self.t[1]

I don't think this form, requiring an additional small helper method,
is any clearer than self.test_exc('self.t[1]', KeyError); two extra
lines and the loss of locality.  Put tests for 3 or 4 different
exceptions into testGetItemFails and you'd have several helper
functions to trace through.

For simple value tests, this is less important; the difference between
test_val( 'self.db.get_user("FOO")', None ) and test_val(None,
self.db.get_user, "foo") is less.

/F's observation that doctest seems suitable for his work is
interesting and surprising; I'll spend some more time looking at it.

--amk



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