Re: annoying doctest problem

2015-01-12 Thread Mark Lawrence
On 12/01/2015 13:00, Steven D'Aprano wrote: Skip Montanaro wrote: ISTR that when Tim Peters first implemented first, the typical way you were expected to get tests into a doc string was to copy from an interactive session, which would not have this problem. I believe that is still documented

Re: annoying doctest problem

2015-01-12 Thread Steven D'Aprano
Skip Montanaro wrote: ISTR that when Tim Peters first implemented first, the typical way you were expected to get tests into a doc string was to copy from an interactive session, which would not have this problem. I believe that is still documented as the way to generate doctests. Also, to

Re: annoying doctest problem

2015-01-12 Thread Skip Montanaro
On Mon, Jan 12, 2015 at 6:15 AM, Skip Montanaro skip.montan...@gmail.com wrote: ... first implemented first ... s/first/doctest/ Darn auto-correct... Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: annoying doctest problem

2015-01-12 Thread Skip Montanaro
ISTR that when Tim Peters first implemented first, the typical way you were expected to get tests into a doc string was to copy from an interactive session, which would not have this problem. Also, to Steven's comment about fussiness, it isn't so much that it's fussy. It's more that it's dumb. I

Re: annoying doctest problem

2015-01-12 Thread Steven D'Aprano
Mark Lawrence wrote: If doctest is dumb then that's clearly down to the author.  Perhaps we should refer him or her to the Zen of Python so they don't repeat the mistake with future design decisions? o_O I don't even ... wait ... [starts typing] [stops typing] ... okay. -- Steven

Re: annoying doctest problem

2015-01-12 Thread Skip Montanaro
On Mon, Jan 12, 2015 at 7:00 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: I didn't mean to give the impression that doctest was wrong to be fussy, or dumb if you prefer. I think it's exactly the right behaviour. I wasn't actually concerned that Steven might have

Re: annoying doctest problem

2015-01-12 Thread Ned Batchelder
On 1/11/15 11:20 PM, gordianknot1...@gmail.com wrote: It failed with an unknown reason that evaluate two expected equal value but got an unexpected result! I'm struggling with this problem for a long time. Did I did something wrong? And how do I to fix it? any help is appreciated. :) My

Re: annoying doctest problem

2015-01-12 Thread Mark Lawrence
On 12/01/2015 15:58, Steven D'Aprano wrote: Mark Lawrence wrote: If doctest is dumb then that's clearly down to the author. Perhaps we should refer him or her to the Zen of Python so they don't repeat the mistake with future design decisions? o_O I don't even ... wait ... [starts

Re: annoying doctest problem

2015-01-12 Thread gordianknot1981
-- My recommendation is to use doctest to test the code samples that naturally occur in your docstrings, but not to use it as a general-purpose testing tool. It has too many limitations and quirks, and if you're going to write

Re: annoying doctest problem

2015-01-11 Thread gordianknot1981
gordian...@gmail.com於 2015年1月12日星期一 UTC+8下午12時20分46秒寫道: #!/usr/bin/python # -*- coding: utf-8 -*- import re kivy_class_ptn = re.compile(r\b[\w_.\@\+]+:?) def test_kivy_class(s): s = MYBT@ToggleButton+Button: test_kivy_class(s) MYBT@ToggleButton+Button:

annoying doctest problem

2015-01-11 Thread gordianknot1981
#!/usr/bin/python # -*- coding: utf-8 -*- import re kivy_class_ptn = re.compile(r\b[\w_.\@\+]+:?) def test_kivy_class(s): s = MYBT@ToggleButton+Button: test_kivy_class(s) MYBT@ToggleButton+Button: s = MYBT test_kivy_class(s) MYBT ret =

Re: annoying doctest problem

2015-01-11 Thread Steven D'Aprano
On Sun, 11 Jan 2015 20:20:35 -0800, gordianknot1981 wrote: [...] Expected: MYBT@ToggleButton+Button: Got: 'MYBT@ToggleButton+Button:' doctest is *very* fussy about the strings matching exactly. You have to use single quotes. I've been burned by this once or twice... -- Steve --