472,374 Members | 1,506 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,374 software developers and data experts.

doctest bug with nested triple quotes

I am getting trouble with nested triple quoted strings in doctest.
For instance

$ cat x.py
"""
dummy = '''

something
here
'''
"""
import doctest; doctest.testmod()

$ python x.py

************************************************** ********************
File "x.py", line 2, in __main__
Failed example:
dummy = '''
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.4/doctest.py", line 1243, in __run
compileflags, 1) in test.globs
File "<doctest __main__[0]>", line 1
dummy = '''
^
SyntaxError: EOF while scanning triple-quoted string
************************************************** ********************

Is this a know bug? Any workaround? Thanks for comments,
Michele Simionato

Aug 2 '05 #1
3 2398
I can't reproduce the error. Freebsd,python 2.4 runs it.
cat x.py """
dummy = '''

something
here
'''
"""
import doctest; doctest.testmod() python x.py

maybe the file is different. python -c "print open('x.py').read().encode('base64')"

IiIiCmR1bW15ID0gJycnCgpzb21ldGhpbmcKaGVyZQonJycKIi IiCmltcG9ydCBkb2N0ZXN0OyBk
b2N0ZXN0LnRlc3Rtb2QoKQo=

Paolino

___________________________________
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB
http://mail.yahoo.it
Aug 2 '05 #2
Michele Simionato wrote:
I am getting trouble with nested triple quoted strings in doctest.
For instance

$ cat x.py
"""
dummy = ''' something
here
'''
"""
import doctest; doctest.testmod()

$ python x.py

************************************************** ********************
File "x.py", line 2, in __main__
Failed example:
dummy = '''
Exception raised:
Traceback (most recent call last):
File "/usr/lib/python2.4/doctest.py", line 1243, in __run
compileflags, 1) in test.globs
File "<doctest __main__[0]>", line 1
dummy = '''
^
SyntaxError: EOF while scanning triple-quoted string
************************************************** ********************

Is this a know bug? Any workaround? Thanks for comments,


I think it is your bug. All lines but the first must be prefixed with
sys.PS2. Just add some dots to make it work:

'''
dummy = """

.... something
.... here
.... """
'''
import doctest; doctest.testmod()

Peter
Aug 2 '05 #3
This is my file
$ python -c "print open('x.py').read().encode('base64')"
IiIiCj4+PiBkdW1teSA9ICcnJwpzb21ldGhpbmcKaGVyZQonJy cKIiIiCmltcG9ydCBkb2N0ZXN0
OyBkb2N0ZXN0LnRlc3Rtb2QoKQo=

but anyway I think Peter Otten is right, the problem is with the
missing dots.
It makes sense, actually, but for some reason I would never have
thought
of it (I did not expect doctest to be so smart to strip the dots even
inside a string).
Thanks for the feeback and the quick solution,

Michele Simionato

Aug 2 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Edward K. Ream | last post by:
Hi, I am trying to run the following docstring using docutils.DocTestSuite: """ >>> s = "a\n \t\n\t\t \t\nb" etc... """ However, docutils complains about "inconsistent leading...
8
by: Christoph Zwerschke | last post by:
I sometimes use triple quotes in order to produce snippets of multiline code, like that: if output == html: snip = '''<html> <head><title>Hello, World</title></head> <body...
2
by: Alan G Isaac | last post by:
> python doctest.py -v Running doctest.__doc__ Trying: .remove(42) Expecting: Traceback (most recent call last): File "<stdin>", line 1, in ? ValueError: list.remove(x): x not in list ok...
7
by: Brian van den Broek | last post by:
Hi all, I'm posting partly so my problem and solution might be more easily found by google, and partly out of mere curiosity. I've just spent a frustrating bit of time figuring out why pydoc...
4
by: 3KWA | last post by:
Hi all, I am wondering what is the standard doctest (test) practice for functions who's returned value change all the time e.g. forex rate: import urllib def get_rate(symbol):...
4
by: so.intech | last post by:
for example, ret = 0; for(i=0; i<3; i ++;) { for(j=0; j<4; j++;) { for(k=0; k<3; k++;) { for(m=0; m<4; m++;) {
5
by: Candace | last post by:
I have to write a program to find all Pythagorean triples for a right triangle. I know that the squares of two sides of the triangle must equal the square of the third (longest) side. However, I...
1
by: Stuart D. Gathman | last post by:
I am trying to create a doctest test case for the following: def quote_value(s): """Quote the value for a key-value pair in Received-SPF header field if needed. No quoting needed for a dot-atom...
12
by: thomas.guest | last post by:
I'm not making progress with the following and would appreciate any help. Here's an interpreted Python session. .... Traceback (most recent call last): File "<stdin>", line 1, in <module>...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.