Issue 13953: Get rid of doctests in packaging.tests.test_version (original) (raw)

Created on 2012-02-06 18:58 by tshepang, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue13953_58bd6a58365d.patch francismb,2012-02-08 19:10 Patch preview review
issue13953_bf6f306ad5cf.patch francismb,2012-02-09 21:07 Patch preview review
cleanup-test_version.diff eric.araujo,2012-02-11 04:56 review
Messages (9)
msg152756 - (view) Author: Tshepang Lekhonkhobe (tshepang) * Date: 2012-02-06 18:58
I'm not sure what's happening here (not sure how doctest works), but I suspect that there is no test at all. Perhaps it was forgotten: http://hg.python.org/cpython/file/567767a6df02/Lib/packaging/tests/test_version.py#l68. I say this because it whatever change I make to that long string, I always get a successful test.
msg152888 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-08 16:46
The interesting line is just after the string: doctest.script_from_examples(comparison_doctest_string) However it looks like there has been a problem with that line, as you can’t get the test to fail, which is strange as I did use that doctest to check #11841! Instead of using time to figure out doctest antics, I will just use good old reliable integrated unittest.
msg152899 - (view) Author: Francis MB (francismb) * Date: 2012-02-08 19:10
Hi here's a patch preview: it has to be re factored further but I stopped here as some tests failed: the out commented ones ... I've checked twice but I cannot see any diff, could you check that? Or, has maybe the behavior (due that bug) changed and nobody noticed? Thanks in advance ! Francis
msg152987 - (view) Author: Francis MB (francismb) * Date: 2012-02-09 21:07
I've done some cleanups
msg153092 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-11 04:56
Thanks, I’ve got it from that point. Notes for future patches: - Tests should not check the exact contents of error messages, as they are not part of the language - Don’t use assertEqual(..., True) but assertTrue, or if you’re testing comparisons, use assertGreater and friends (or check the result of sorted(somelist) to compare a bunch of objects at once)
msg153113 - (view) Author: Francis MB (francismb) * Date: 2012-02-11 09:20
Thank you for the review. Just some questions: Isn't that what the previous code (doctest code) did? I thought that the code should be ported as far backwards as possible and that's why I used the plain assertEqual (I don't know exactly in with version the other assert methods were introduced. Unittest2?) Can one use all the new unittest2 methods to test packaging (distutils2) code? > ---------- > Added file: http://bugs.python.org/file24482/cleanup-test_version.diff > > _______________________________________ > Python tracker<report@bugs.python.org> > <http://bugs.python.org/issue13953> > _______________________________________ >
msg153150 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-12 03:08
> Isn't that what the previous code (doctest code) did? I don’t understand, could you rephrase? > I thought that the code should be ported as far backwards as possible and that's why I > used the plain assertEqual (I don't know exactly in with version the other assert > methods were introduced. Unittest2?) Michael Foord took over maintenance of unittest and released a bunch of improvements for 2.7 and 3.1, then further improvements in 3.2. unittest2 is a standalone release of this improved unittest (not sure if it’s like 3.1 or 3.2). For packaging in the 3.3 stdlib we have all new methods, and for distutils2 we use unittest2 which has them too and works with 2.4, so we have compat.
msg153193 - (view) Author: Francis MB (francismb) * Date: 2012-02-12 10:08
Does a "doc test" test the output literally? (I've just always used unittest) Ok, thanks
msg153339 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2012-02-14 15:37
> Does a "doc test" test the output literally? Yes, that’s the problem. See doctest documentation for more info about how it works and what problems it has.
History
Date User Action Args
2022-04-11 14:57:26 admin set github: 58161
2014-03-13 02:43:18 eric.araujo set status: open -> closedresolution: out of datestage: resolved
2012-02-18 01:14:43 eric.araujo unlink issue13948 superseder
2012-02-14 15:37:37 eric.araujo set messages: +
2012-02-12 10:08:04 francismb set messages: +
2012-02-12 04:01:18 eric.araujo link issue13948 superseder
2012-02-12 03:46:23 eric.araujo link issue13949 superseder
2012-02-12 03:44:44 eric.araujo link issue13950 superseder
2012-02-12 03:08:44 eric.araujo set messages: +
2012-02-11 09:20:16 francismb set messages: +
2012-02-11 04:56:31 eric.araujo set files: + cleanup-test_version.diffmessages: +
2012-02-09 21:07:43 francismb set files: + issue13953_bf6f306ad5cf.patchmessages: +
2012-02-08 19:10:46 francismb set files: + issue13953_58bd6a58365d.patchkeywords: + patchmessages: +
2012-02-08 16:46:58 eric.araujo set assignee: tarek -> eric.araujotitle: test_packaging: unused test? -> Get rid of doctests in packaging.tests.test_versionmessages: + versions: + 3rd party
2012-02-06 23:29:50 francismb set nosy: + francismb
2012-02-06 18:58:59 tshepang create