Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Neil Cerutti
On 2013-09-22, Luca Cerone luca.cer...@gmail.com wrote: I understand your point, but now I am not writing unit tests to check the correctness of the code. I am only writing a tutorial and assuming that the code is correct. What I have to be sure is that the code in the tutorial can be executed

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Luca Cerone
It won't be very good documenation any more but nothing stops you from examining the result in the next doctest and making yourself happy about it. x = input(indeterminate:) result = '{}'.format(x)) result.startswith(') and result.endswith(') True Hi Neil,

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Luca Cerone
I don't know why but it seems that google groups stripped the indentation from the code. I just wanted to ensure you that in the examples that I have run the definition of myfunc contained correctly indented code! On Monday, 23 September 2013 15:45:43 UTC+1, Luca Cerone wrote: .. doctest::

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Skip Montanaro
I don't know why but it seems that google groups stripped the indentation from the code. Because it's Google Groups. :-) 800-pound gorillas tend to do pretty much whatever they want. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Neil Cerutti
On 2013-09-23, Neil Cerutti ne...@norwich.edu wrote: Perhaps try the advanced API and define your oen OutputChecker to add the feature that you need. Figuring out how to best invoke doctest with your modified OutputChecker will take some digging in the source, probably looking at

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Neil Cerutti
On 2013-09-23, Luca Cerone luca.cer...@gmail.com wrote: It won't be very good documenation any more but nothing stops you from examining the result in the next doctest and making yourself happy about it. x = input(indeterminate:) result = '{}'.format(x))

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-23 Thread Luca Cerone
The docstring for doctest.DocTestRunner contains the example code I was looking for. Thanks, I will give it a try! -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-22 Thread Steven D'Aprano
On Sat, 21 Sep 2013 21:15:48 -0700, Luca Cerone wrote: I am looking for a way to test the code while ignoring the output. This makes no sense. If you ignore the output, the code could do ANYTHING and the test would still pass. Raise an exception? Pass. SyntaxError? Pass. Print 99 bottles of

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-22 Thread Ned Batchelder
On 9/22/13 12:09 AM, Luca Cerone wrote: Hi Chris, actually my priority is to check that the code is correct. I changed the syntax during the development, and I want to be sure that my tutorial is up to date. If you do manage to ignore the output, how will you know that the syntax is correct?

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-22 Thread Luca Cerone
This makes no sense. If you ignore the output, the code could do ANYTHING and the test would still pass. Raise an exception? Pass. SyntaxError? Pass. Print 99 bottles of beer? Pass. if you try the commands, you can see that the tests fail.. for example .. doctest:: raise

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-22 Thread Luca Cerone
On Sunday, 22 September 2013 14:39:07 UTC+1, Ned Batchelder wrote: On 9/22/13 12:09 AM, Luca Cerone wrote: Hi Chris, actually my priority is to check that the code is correct. I changed the syntax during the development, and I want to be sure that my tutorial is up to date.

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-22 Thread Steven D'Aprano
On Sun, 22 Sep 2013 09:39:07 -0400, Ned Batchelder wrote: On 9/22/13 12:09 AM, Luca Cerone wrote: Hi Chris, actually my priority is to check that the code is correct. I changed the syntax during the development, and I want to be sure that my tutorial is up to date. If you do manage to

Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Luca Cerone
Dear all, I am writing the documentation for a Python package using Sphinx. I have a problem when using doctest blocks in the documentation: I couldn't manage to get doctest to run a command but completely ignoring the output. For example, how can I get a doctest like the following to run

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Steven D'Aprano
On Sat, 21 Sep 2013 03:47:26 -0700, Luca Cerone wrote: Dear all, I am writing the documentation for a Python package using Sphinx. I have a problem when using doctest blocks in the documentation: I couldn't manage to get doctest to run a command but completely ignoring the output. For

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Luca Cerone
Dear Steven, thanks for the help. I am aware that I might have used the SKIP directive (as I hinted in my mail). Even if the fine manual suggests to do so I don't agree with it, though. The reason is simple: SKIP as the name suggests causes the code not to be run at all, it doesn't ignore the

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Steven D'Aprano
On Sat, 21 Sep 2013 05:44:09 -0700, Luca Cerone wrote: If you use a SKIP directive on code that contains a typo, or maybe you changed the name of a keyword to make it more meaningful and forgot to update your docstring, then the error won't be caught. And if you ignore the output, the error

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Luca Cerone
And if you ignore the output, the error won't be caught either. What's the difference? 1 + 1 #doctest:+IGNORE_OUTPUT (not a real directive) 1000 The difference is that in that case you want to check whether the result is correct or not, because you expect a certain result. In

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Chris Angelico
On Sun, Sep 22, 2013 at 2:25 AM, Luca Cerone luca.cer...@gmail.com wrote: The difference is that in that case you want to check whether the result is correct or not, because you expect a certain result. In my case, I don't know what the output is, nor care for the purpose of the tutorial.

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Steven D'Aprano
On Sat, 21 Sep 2013 09:25:26 -0700, Luca Cerone wrote: And if you ignore the output, the error won't be caught either. What's the difference? 1 + 1 #doctest:+IGNORE_OUTPUT (not a real directive) 1000 The difference is that in that case you want to check whether the result is

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Luca Cerone
but if you're using this for a tutorial, you risk creating a breed of novice programmers who believe their first priority is to stop the program crashing. Smoke testing is Hi Chris, actually my priority is to check that the code is correct. I changed the syntax during the development, and

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Luca Cerone
That is not how doctest works. That test fails because its output is: ok.. is there a tool by which I can test if my code runs regardless the output? The only wild-card output that doctest recognises is ellipsis, and like all wild-cards, can match too much if you aren't careful. If

Re: Sphinx Doctest: test the code without comparing the output.

2013-09-21 Thread Chris Angelico
On Sun, Sep 22, 2013 at 2:09 PM, Luca Cerone luca.cer...@gmail.com wrote: but if you're using this for a tutorial, you risk creating a breed of novice programmers who believe their first priority is to stop the program crashing. Smoke testing is Hi Chris, actually my priority is to check