[Zope3-dev] Re: doctest prb again

2007-07-20 Thread Philipp von Weitershausen

Adam Groszer wrote:

Great, that works ;-)
Thought that there is some more genreic-sane way.


There is. NORMALIZE_WHITESPACE actually only helps when whatever you're 
outputting actually prints whitespace. Doing this::


   '   '
  '   '

won't invoke the whitespace normalizer. Doing this::

  print '   '
 three spaces

will invoke it, though.



Friday, July 20, 2007, 10:25:02 AM, you wrote:

On Fri, Jul 20, 2007 at 10:09:18AM +0200, Adam Groszer wrote:

Hello,

How to solve the \r\n and \n mismatch between win32 and *nix in the
doctests?

doctest is:

 ctrl.value
'Text inside\narea!\n  '


fails with (on win32):

Failed example:
ctrl.value
Expected:
'Text inside\narea!\n  '
Got:
'  Text inside\r\n  area!\r\n'


ctrl.value comes from a html file in zope.testbrowser.ftests



You could do



 ctrl.value.replace('\r', '')



or strip the \r's in the place where you're reading that html file.



Marius Gedminas





--
http://worldcookery.com -- Professional Zope documentation and training
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com



[Zope3-dev] Re: doctest prb again

2007-07-20 Thread Marius Gedminas
On Fri, Jul 20, 2007 at 11:30:08AM +0200, Philipp von Weitershausen wrote:
 Adam Groszer wrote:
 Great, that works ;-)
 Thought that there is some more genreic-sane way.
 
 There is. NORMALIZE_WHITESPACE actually only helps when whatever you're 
 outputting actually prints whitespace. Doing this::
 
'   '
   '   '
 
 won't invoke the whitespace normalizer.

I'm pretty certain you're mistaken here:

 import doctest
 def test1():
... 
...  '   ' # doctest: +NORMALIZE_WHITESPACE
... ' '
... 
... 
 doctest.testmod()
(0, 1)

The test passes.  What wouldn't work, though, is if you tried to match
whitespace that is not expressed as whitespace in your test, e.g. tabs:

 def test2():
... r
...  '\t\t ' # doctest: +NORMALIZE_WHITESPACE
... '\t'
... 
... 
 doctest.testmod()
**
File /home/mg/.python, line 25, in __main__.test2
Failed example:
'\t\t' # doctest: +NORMALIZE_WHITESPACE
Expected:
'\t'
Got:
'\t\t'
**
1 items had failures:
   1 of   1 in __main__.test2
***Test Failed*** 1 failures.
*** DocTestRunner.merge: '__main__.test1' in both testers; summing outcomes.
*** DocTestRunner.merge: '__main__' in both testers; summing outcomes.
(1, 2)

Marius Gedminas
-- 
America and England are two countries separated by a common language.


signature.asc
Description: Digital signature
___
Zope3-dev mailing list
Zope3-dev@zope.org
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com