[Tutor] doctest: how to test a single function?

2015-05-06 Thread Slater Joseph C , PhD, PE
I'm an admitted newb trying to enter the Python community and use Python significantly (versus occassionally). dockets seems to be much more powerful than I can figure out how to tap. I have a function inside a file that's an embedded test that (currently) works fine. However, the package has

Re: [Tutor] doctest question

2012-11-27 Thread Steven D'Aprano
On 27/11/12 20:50, Albert-Jan Roskam wrote: Function name "_setMultRespDefsEx" is not self-explanatory, or even *hint* at what the function is supposed to do. It appears to take a dictionary of stuff, and formats it as a string. It would be nice[1] if your docstring explained what sort of stuff.

Re: [Tutor] doctest question

2012-11-27 Thread Dave Angel
On 11/27/2012 04:50 AM, Albert-Jan Roskam wrote: > >> On 27/11/12 08:06, Albert-Jan Roskam wrote: >>> (Steven D'Aprano wrote, even though the indentation is wrong) >>> >>> >>> >>> Doctesting anything to do with dictionaries is tricky, because you >>> cannot rely on the order of a dict. There are

Re: [Tutor] doctest question

2012-11-27 Thread Albert-Jan Roskam
  > On 27/11/12 08:06, Albert-Jan Roskam wrote: >> Hi, >> >> I am using doctest and I am struggling with newlines characters >> (see below). One is the newline escape (backslash) for a long >> dictionary definition. The other is an embedded \n in the output. >> I used the +NORMALIZE_WHITESPACE dir

Re: [Tutor] doctest question

2012-11-26 Thread Steven D'Aprano
On 27/11/12 09:02, Steven D'Aprano wrote: Here's my attempt: def _setMultRespDefsEx(multRespDefs): """Format a dictionary of stuff as a string. Expects that dict contains: [...] KNOWN BUGS: 1) Sometimes this function returns a dict instead of a string. 2) The formatted string output is amb

Re: [Tutor] doctest question

2012-11-26 Thread Steven D'Aprano
On 27/11/12 08:06, Albert-Jan Roskam wrote: Hi, I am using doctest and I am struggling with newlines characters (see below). One is the newline escape (backslash) for a long dictionary definition. The other is an embedded \n in the output. I used the +NORMALIZE_WHITESPACE directive. I also tried

[Tutor] doctest question

2012-11-26 Thread Albert-Jan Roskam
Hi, I am using doctest and I am struggling with newlines characters (see below). One is the newline escape (backslash) for a long dictionary definition. The other is an embedded \n in the output. I used the +NORMALIZE_WHITESPACE directive. I also tried using a triple-quoted raw docstring. Any id

Re: [Tutor] Doctest error!

2011-11-17 Thread Dave Angel
On 11/17/2011 10:56 PM, Nidian Job-Smith wrote: Date: Thu, 17 Nov 2011 22:49:33 -0500 From: d...@davea.name To: nidia...@hotmail.com CC: tutor@python.org Subject: Re: [Tutor] Doctest error! On 11/18/2011 10:29 AM, John wrote: Hi all, When i run a

Re: [Tutor] Doctest error!

2011-11-17 Thread Nidian Job-Smith
> Date: Thu, 17 Nov 2011 22:49:33 -0500 > From: d...@davea.name > To: nidia...@hotmail.com > CC: tutor@python.org > Subject: Re: [Tutor] Doctest error! > > On 11/18/2011 10:29 AM, John wrote: > > > > Hi all, > > Whe

Re: [Tutor] Doctest error!

2011-11-17 Thread Dave Angel
On 11/18/2011 10:29 AM, John wrote: Hi all, When i run a doctest on this piece of code (shown at bottom) i get this error message [from the doctest]: Trying: rot13('5 The Parade') Expecting: '5 Gur Cnenqr' ** File "

[Tutor] Doctest error!

2011-11-17 Thread John
Hi all, When i run a doctest on this piece of code (shown at bottom) i get this error message [from the doctest]: Trying: rot13('5 The Parade') Expecting: '5 Gur Cnenqr' ** File "F:\Uni\Rot13_1.py", line 12, in Rot13_

Re: [Tutor] Doctest, object references and the use of ellipses

2006-04-01 Thread Tim Peters
[Tim Peters] >> That "should work", provided there aren't differences in whitespace >> that are invisible to us in this medium. For example, if, in your >> source file, there's actually a (one or more) trailing space on your >> line of expected output, then it would _not_ match the actual output.

Re: [Tutor] Doctest, object references and the use of ellipses

2006-04-01 Thread Don Taylor
Tim Peters wrote: > That "should work", provided there aren't differences in whitespace > that are invisible to us in this medium. For example, if, in your > source file, there's actually a (one or more) trailing space on your > line of expected output, then it would _not_ match the actual output

Re: [Tutor] Doctest, object references and the use of ellipses

2006-04-01 Thread Tim Peters
[Don Taylor] > I am trying to use Doctest and am having trouble using the ellipsis > feature when trying to match an object reference. > > Here is the code: > > def add_change_listener(self, listener): > ''' > > Returns list of listeners just for testing. > >>> def m

Re: [Tutor] Doctest, object references and the use of ellipses

2006-04-01 Thread Don Taylor
Kent Johnson wrote: > Don Taylor wrote: > >>Hi: >> >>I am trying to use Doctest and am having trouble using the ellipsis >>feature when trying to match an object reference. > > > What version of Python are you using? The ELLIPSIS comment was added in > Python 2.4. > I am using 2.4.2 Don. _

Re: [Tutor] Doctest, object references and the use of ellipses

2006-04-01 Thread Kent Johnson
Don Taylor wrote: > Hi: > > I am trying to use Doctest and am having trouble using the ellipsis > feature when trying to match an object reference. What version of Python are you using? The ELLIPSIS comment was added in Python 2.4. Kent > > Here is the code: > > def add_change_listener

[Tutor] Doctest, object references and the use of ellipses

2006-04-01 Thread Don Taylor
Hi: I am trying to use Doctest and am having trouble using the ellipsis feature when trying to match an object reference. Here is the code: def add_change_listener(self, listener): ''' Returns list of listeners just for testing. >>> def mock_listener():

Re: [Tutor] doctest

2005-01-02 Thread Kent Johnson
Alan Gauld wrote: Also, anything I can do... Presently, since I'm running windows xp, I would have to hunt for the command prompt and type in the command Start->Run Type cmd, Hit OK :-) Or drag the icon from accessories into the start menu or to the desktop. Or drag the icon to the left side of th

Re: [Tutor] doctest

2005-01-02 Thread Kent Johnson
Jacob S. wrote: Even so, doctest doesn't seem to recognize the module level docstring. It will run the test inside the functions, but it says there isn't a test on the module level. I put the docstring just like in the example at the link you provided... Please post the code for the module you are

Re: [Tutor] doctest

2005-01-02 Thread Alan Gauld
> Also, anything I can do... Presently, since I'm running windows xp, I would > have to hunt for the command prompt and type in the command Start->Run Type cmd, Hit OK :-) Or drag the icon from accessories into the start menu or to the desktop. > '"C:\python24\python.exe" "C:\documents and sett

Re: [Tutor] doctest

2005-01-01 Thread Patric Michael
> Also, anything I can do... Presently, since I'm running windows xp, I > would have to hunt for the command prompt and type in the command Click Start, click Run, type CMD, press Enter. Voila! :) Patric > > '"C:\python24\python.exe" "C:\documents and > settings\jacob\desktop\working python

Re: [Tutor] doctest

2005-01-01 Thread Jacob S.
I forgot to mention... When I explicitly define the variable __doc__ at the module level, it *does* recognize the module level docstring. > I think I'm losing my mind... > > Maybe it's because I go back to school the day after tomorrow? > The thing that helped the most was the -v parameter... > >

Re: [Tutor] doctest

2005-01-01 Thread Jacob S.
I think I'm losing my mind... Maybe it's because I go back to school the day after tomorrow? The thing that helped the most was the -v parameter... Even so, doctest doesn't seem to recognize the module level docstring. It will run the test inside the functions, but it says there isn't a test on t

Re: [Tutor] doctest

2005-01-01 Thread Kent Johnson
What docs are you looking at?? The module docs at http://docs.python.org/lib/module-doctest.html have a complete example of testing a module with a main function. Or you can use the code in my last post. Kent Jacob S. wrote: Hi. Okay, so I look at the documentation at it says (in my words):

[Tutor] doctest

2005-01-01 Thread Jacob S.
Hi. Okay, so I look at the documentation at it says (in my words): "First Class - DocTest -- Make a test object with such and such attributes that you can test. Second Class - i don't remember the name - Make Jacob look stupid with big words Third Class - DocTestSuite - Convert a doctest obje