classification
Title: doctest option flag to enable/disable some chunk of doctests?
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.4
process
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.

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
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: + test.py

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