Issue 9017: doctest option flag to enable/disable some chunk of doctests? (original) (raw)

Created on 2010-06-17 12:42 by harobed, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py harobed,2010-10-06 11:21
Messages (8)
msg108008 - (view) Author: harobed (harobed) Date: 2010-06-17 12:42
Hi, in some doctest, I need to stop doctest from a position because the following test is a draft, not implemented. I dream something like this : >>> test_a() True >>> test_b() False #doctest: +DISABLE >>> test_c() True >>> test_d() False #doctest: +ENABLE >>> test_e() True >>> test_f() False Here, test_c and test_d aren't executed. What do you think about this idea ? If it is a good idea, I can implement it. Thanks for your comments, Stephane
msg118037 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-10-05 22:28
There is already doctest.SKIP. Isn't it already what you want?
msg118056 - (view) Author: harobed (harobed) Date: 2010-10-06 08:07
doctest.SKIP is like #doctest: +DISABLE but he don't have #doctest: +ENABLE feature. doctest.SKIP disable all the bottom of test, DISABLE/ENABLE can SKIP only one part of test. Regards, Stephane
msg118058 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-10-06 08:58
I'm not a great doctest user, but did you try to disable the SKIP directive at the end? something like "doctest: -SKIP"
msg118059 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-10-06 08:59
AFAIR +SKIP always only refers to one Example anyway.
msg118061 - (view) Author: harobed (harobed) Date: 2010-10-06 11:21
Ok, option +SKIP and -SKIP work well, look test.py file I need maybe improve the documentation with an +SKIP and -SKIP example ? Documentation section about SKIP option is here : http://docs.python.org/library/doctest.html?highlight=doctest.skip#doctest.SKIP Regards, Stephane
msg118063 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2010-10-06 11:44
harobed, the -SKIP solution does not work. Doctest directives only apply to a single line. After a quick search, I found two workarounds there: http://stackoverflow.com/questions/1809037/python-doctest-skip-entire-block - Replace >>> with >> or - split the docstring, and add something like "__dont_test__ = " in front of the second part; the string becomes part of a statement and won't be parsed.
msg173979 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-10-27 21:27
I'm going to close this as rejected, because the feature doesn't seem too useful, there are available workarounds, and the addition of the ENABLE/DISABLE flags might add confusions.
History
Date User Action Args
2022-04-11 14:57:02 admin set github: 53263
2012-10-27 21:27:18 ezio.melotti set status: open -> closedversions: + Python 3.4, - Python 3.3nosy: + ezio.melottimessages: + resolution: rejectedstage: needs patch -> resolved
2010-12-22 08:13:08 eric.araujo set nosy: + eric.araujostage: test needed -> needs patchversions: + Python 3.3, - Python 3.2
2010-10-06 11:44:54 amaury.forgeotdarc set messages: +
2010-10-06 11:21:37 harobed set files: + test.pymessages: +
2010-10-06 08:59:53 georg.brandl set nosy: + georg.brandlmessages: +
2010-10-06 08:58:16 amaury.forgeotdarc set messages: +
2010-10-06 08:07:49 harobed set messages: +
2010-10-05 22:28:20 amaury.forgeotdarc set nosy: + amaury.forgeotdarcmessages: +
2010-06-17 13:46:28 brian.curtin set title: What do you think about an Option Flags to enable/disable some chunk of doctest file ? -> doctest option flag to enable/disable some chunk of doctests?versions: + Python 3.2type: enhancementcomponents: + Library (Lib), - Testsstage: test needed
2010-06-17 12:42:11 harobed create