Title: doctest option flag to enable/disable some chunk of doctests?
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.4
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, eric.araujo, ezio.melotti, georg.brandl, harobed
Priority: normal Keywords:

Created on 2010-06-17 12:42 by harobed, last changed 2012-10-27 21:27 by ezio.melotti. This issue is now closed.

File name Uploaded Description Edit harobed, 2010-10-06 11:21
Messages (8)
msg108008 - (view) Author: harobed (harobed) Date: 2010-06-17 12:42

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()

   >>> test_b()

   #doctest: +DISABLE

   >>> test_c()

   >>> test_d()

   #doctest: +ENABLE

   >>> test_e()

   >>> test_f()

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,
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.

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 file

I need maybe improve the documentation with an +SKIP and -SKIP example ?

Documentation section about SKIP option is here :

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:
- Replace >>> with >>
- 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.
Date User Action Args
2012-10-27 21:27:18ezio.melottisetstatus: open -> closed

versions: + Python 3.4, - Python 3.3
nosy: + ezio.melotti

messages: + msg173979
resolution: rejected
stage: needs patch -> resolved
2010-12-22 08:13:08eric.araujosetnosy: + eric.araujo
stage: test needed -> needs patch

versions: + Python 3.3, - Python 3.2
2010-10-06 11:44:54amaury.forgeotdarcsetmessages: + msg118063
2010-10-06 11:21:37harobedsetfiles: +

messages: + msg118061
2010-10-06 08:59:53georg.brandlsetnosy: + georg.brandl
messages: + msg118059
2010-10-06 08:58:16amaury.forgeotdarcsetmessages: + msg118058
2010-10-06 08:07:49harobedsetmessages: + msg118056
2010-10-05 22:28:20amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg118037
2010-06-17 13:46:28brian.curtinsettitle: 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.2
type: enhancement
components: + Library (Lib), - Tests
stage: test needed
2010-06-17 12:42:11harobedcreate