single-quoted string conversion to triple-quoted string

robin and jim robinjim at earthlink.net
Sat Apr 6 07:38:19 EST 2002


Gee, I thought it would be obvious why I was asking such a question <wink>!

As unit tests run, using the unittest module shipped with Python 2.2,  the
default behavior is to display a one-line description of each test. The
default implementation displays the first line of the test method's
**docstring**, if available; otherwise the name of the test method (e.g.,
"test_my_regular_expression") is displayed.

Well, yours truly thought he would be clever and add some additional
information to this docstring as it became available at run time via the %
placeholder mechanism.  Alas, the result is a single-quoted string that
unittest does not recognize as a docstring so it displays the test method's
name (e.g., "test_my_regular_expression") instead. I, naively, think that if
the single quoted result can be re-converted to a triple-quoted string, it
will be recognized by unittest.

Hope this helps clarify what I'm asking -- and thanks for your interest.

"robin and jim" <robinjim at earthlink.net> wrote in message
news:GZqr8.20207$ml2.1517221 at newsread1.prod.itd.earthlink.net...
> Is there a way to convert a single quoted string to a triple quoted
string?
>
> For example, given:
>
> ''' abc %d xyz '''
>
> the result of ''' abc %d xyz''' % 10 is:
>
> ' abc 10 xyz '
>
> which is a single quoted string.
>
> I would like to convert the result to a triple-quoted string.
>
>
>





More information about the Python-list mailing list