classification
Title: Using modern unittest asserts in the documentation
Type: enhancement Stage: patch review
Components: Documentation, Tests Versions: Python 3.2, Python 3.3, Python 3.4
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: docs@python, ezio.melotti, michael.foord, rhettinger, serhiy.storchaka
Priority: normal Keywords: easy, patch

Created on 2012-12-22 08:34 by serhiy.storchaka, last changed 2012-12-24 08:47 by ezio.melotti. This issue is now closed.

Files
File name Uploaded Description Edit
docs_unittest_assert.patch serhiy.storchaka, 2012-12-22 08:34 review
Messages (6)
msg177924 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-22 08:34
The proposed patch update the documentation examples to use more modern unittest asserts.
msg178030 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2012-12-24 05:04
Please don't change the Basic Example section.  It is designed to get people up and running with a minimal set of asserts (including assertEqual, assertTrue, and the two ways of using assertRaises).  "Modernizing" the example will defeat its purpose.
msg178031 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-12-24 07:08
See also #11468.
msg178032 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-12-24 07:22
But with the patch the minimal set of asserts will be assertEqual, assertIn, and assertRaises. The example is just too old (assertIn was added in 3.1). If you want to minimize assert's set, you can get rid of assertEqual too (using only assertTrue). But I don't think it is a good idea.
msg178038 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2012-12-24 08:39
Sorry, I'm going to reject this one.

FWIW, I'm working on revising the example anyway (to not use the random module and instead test something more straight-forward).
msg178039 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-12-24 08:47
Raymond, the changes in the "mock" documentation look good to me, and I think they can be applied.

Regarding the basic example in the "unittest" doc, I think the patch attached to #11468 (or something similar) should be applied instead.  That patch uses straight-forward string methods and the basic assertEqual/True/False/Raises.
History
Date User Action Args
2012-12-24 08:47:55ezio.melottisetmessages: + msg178039
2012-12-24 08:39:48rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg178038
2012-12-24 07:22:56serhiy.storchakasetmessages: + msg178032
2012-12-24 07:08:53ezio.melottisetnosy: + ezio.melotti
messages: + msg178031
2012-12-24 05:04:17rhettingersetassignee: docs@python -> rhettinger

messages: + msg178030
nosy: + rhettinger
2012-12-22 14:54:17r.david.murraysetnosy: + michael.foord
2012-12-22 08:34:03serhiy.storchakacreate