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.

classification
Title: Add summary tables for unittest API
Type: enhancement Stage: resolved
Components: Documentation, Tests Versions: Python 3.1, Python 3.2, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ezio.melotti Nosy List: eric.araujo, ezio.melotti, michael.foord, rhettinger, terry.reedy
Priority: normal Keywords: patch

Created on 2010-09-08 00:43 by eric.araujo, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue9796.diff ezio.melotti, 2010-11-01 13:21 Proof of concept of the assert* methods table review
issue9796-2.diff ezio.melotti, 2010-11-01 21:29 Tables for all the assert* methods review
issue9796-3.diff ezio.melotti, 2010-11-02 12:45 Improved tables for all the assert* methods review
issue9796-4.diff ezio.melotti, 2010-11-02 16:05 Improved tables for all the assert* methods review
Messages (11)
msg115833 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-09-08 00:43
Suggestion from Raymond: Add a table summarizing all assert* methods of TestCase. I will make a patch in some days or weeks. I think I’ll also add one table for the most useful objects from a user viewpoint (Loader, TestCase, main). See the docs of itertools and collections for examples of such summary tables.
msg115852 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2010-09-08 07:12
Just focus on the table for assert* methods.  This is the one category that users will need to look-up over and over again.  The goal is to make the docs more usable, not more voluminous.

Also, I suggest finding meaningful groupings (don't stick with alpha order) and including a short plain assert-statement equivalents to show what the methods actual do (this is important because many are new, some are obscure, and not all have obvious semantics):

 | assertEqual(x, y)          | assert x == y                      |
 | assertGreaterThan(x, y)    | assert x > y                       |
 | assertItemsEqual(act, exp) | assert sorted(exp) == sorted(act)  |
msg115934 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2010-09-09 10:21
This has been on my 'todo list' for a long time. Feel free to get to it before me. Please *don't* include the now deprecated assert* methods in the table. I'd like to move all the deprecated methods to a separate section of the documentation.

As Raymond says - just the assert* methods from TestCase will be the biggest value for the unittest docs, so +1 to his comment (and suggestion on grouping and including example).
msg120124 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-11-01 13:21
The attached patch adds a table with the most common assert* methods and their explanation at the top of the doc.

There are however a few things that should imho be changed, but that will require some re-organization in the unittest doc:

1) now the table is on the third "screen" and it's necessary to scroll down to reach it. It would be better to move it in an higher position or add a link at the top of the doc to the assert* methods section with the tables;
2) all the assert methods should be in a table. More tables can be used, e.g.:
  * one with the common methods (the ones in the patch);
  * one with other "comparison" methods like assertLess and friends, assert[Not]AlmostEqual (these could be included in the first table though);
  * one for exceptions and warnings (assertRaises, assertWarn, assertRaisesRegexp, ...);
  * one for "advanced" methods (assertItemsEqual, assertDictContainsSubset, assertSequenceEqual, ...);
  * one for the type-specific methods used by assertEqual (assertSetEqual, assertListEqual, ...), saying that they are used automatically by assertEqual and possibly that they shouldn't be used directly.
3) the doc of the methods should be right after the table that lists them;
4) other non-assert methods shouldn't be mixed with the assert* methods -- the assert* methods should have their own section;
5) other methods could be grouped in tables too (setUp, tearDown, ...; skip*);
msg120180 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-11-01 21:29
I implemented 2) and 3) in issue9796-2.diff.
msg120218 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-11-02 12:45
issue9796-3.diff improves the rendering of the HTML tables. (Note: the patch just adds the tables, short paragraphs before them and moves a few methods around to match the division and the order of the tables, without changing their content.)
msg120235 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-11-02 16:05
Updated patch after the changes made in r86118.
msg120353 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2010-11-03 23:14
I committed the patch in r86141 and a few other fixes in r86142 and r86143. There are still more things I want to fix before I backport all the patches to 3.1 and 2.7 and close the issue.
msg130409 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2011-03-09 03:21
I just read through the 3.2 unittest doc and found and will find the new tables very helpful. I hope you get them into the upcoming 3.1.3 and 2.7.2 releases, even if you think them not complete ;-).
msg130503 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-03-10 11:57
The tables and several other doc changes went in 3.1 in cb3a925de1bd.
msg130527 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-03-10 21:07
And in 2.7 in 6e5b5d1b6714.
There's some more refactoring that could be done on unittest.rst but it's out of the scope of this issue, so I'm closing this.
History
Date User Action Args
2022-04-11 14:57:06adminsetgithub: 54005
2011-03-10 21:07:20ezio.melottisetstatus: open -> closed
nosy: rhettinger, terry.reedy, ezio.melotti, eric.araujo, michael.foord
messages: + msg130527

resolution: fixed
stage: commit review -> resolved
2011-03-10 11:57:27ezio.melottisetnosy: rhettinger, terry.reedy, ezio.melotti, eric.araujo, michael.foord
messages: + msg130503
2011-03-09 03:21:19terry.reedysetnosy: + terry.reedy

messages: + msg130409
versions: + Python 3.3
2010-11-03 23:14:35ezio.melottisetmessages: + msg120353
stage: needs patch -> commit review
2010-11-02 16:05:14ezio.melottisetfiles: + issue9796-4.diff

messages: + msg120235
2010-11-02 12:45:31ezio.melottisetfiles: + issue9796-3.diff

messages: + msg120218
components: + Tests
2010-11-01 21:29:53ezio.melottisetfiles: + issue9796-2.diff
assignee: eric.araujo -> ezio.melotti
messages: + msg120180
2010-11-01 13:21:47ezio.melottisetfiles: + issue9796.diff
type: enhancement
messages: + msg120124

keywords: + patch
2010-09-09 10:21:00michael.foordsetmessages: + msg115934
2010-09-08 07:12:05rhettingersetmessages: + msg115852
2010-09-08 04:14:48ezio.melottisetnosy: + ezio.melotti
2010-09-08 00:43:40eric.araujocreate