[issue16751] Using modern unittest asserts in the documentation

New submission from Serhiy Storchaka: The proposed patch update the documentation examples to use more modern unittest asserts. ---------- assignee: docs@python components: Documentation, Tests files: docs_unittest_assert.patch keywords: easy, patch messages: 177924 nosy: docs@python, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Using modern unittest asserts in the documentation type: enhancement versions: Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file28394/docs_unittest_assert.patch _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Changes by R. David Murray <rdmurray@bitdance.com>: ---------- nosy: +michael.foord _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Raymond Hettinger added the comment: 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. ---------- assignee: docs@python -> rhettinger nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Ezio Melotti added the comment: See also #11468. ---------- nosy: +ezio.melotti _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Serhiy Storchaka added the comment: 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Raymond Hettinger added the comment: 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). ---------- resolution: -> rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Ezio Melotti added the comment: 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Changes by R. David Murray <rdmurray@bitdance.com>: ---------- nosy: +michael.foord _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Raymond Hettinger added the comment: 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. ---------- assignee: docs@python -> rhettinger nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Ezio Melotti added the comment: See also #11468. ---------- nosy: +ezio.melotti _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Serhiy Storchaka added the comment: 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Raymond Hettinger added the comment: 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). ---------- resolution: -> rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________

Ezio Melotti added the comment: 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. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue16751> _______________________________________
participants (4)
-
Ezio Melotti
-
R. David Murray
-
Raymond Hettinger
-
Serhiy Storchaka