This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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
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 2022-04-11 14:57 by admin. This issue is now closed.

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.
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60955
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