[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: HEADS UP: cmdline test factory

From: David James <james82_at_gmail.com>
Date: Sun, 21 Jun 2009 13:59:08 -0700

On Sun, Jun 21, 2009 at 1:52 PM, Neels J Hofmeyr<neels_at_elego.de> wrote:
> David James wrote:
>> On Sat, Jun 20, 2009 at 3:59 PM, Neels Janosch Hofmeyr<neels_at_elego.de> wrote:
>>> This is how I implemented the same test cmpilato wrote in about two minutes
>>> sharp:
>>>
>>> [[[
>>> def mine(sbox):
>>>  "lock a file using a comment with xml special chars"
>>>  svntest.factory.make(sbox, """
>>>                       echo "This represents a binary file\\n" >> iota
>>>                       svn ci
>>>                       svn lock -m 'lock & load' iota
>>>                       """)
>>> ]]]
>>> (Note that I had to double-escape the '\n' to '\\n' because of python
>>> parsing it before factory can.)
>>
>> This sounds very useful! I like how it simplifies the test suite. I
>> just have a drive-by suggestion for you here. If you don't want Python
>> to interpret the backslashes, use raw strings. In that case, you don't
>> need to double-escape. E.g.
>>
>> [[[
>>   svntest.factory.make(sbox, r"""
>>                        echo "This represents a binary file\n" >> iota
>>                        svn ci
>>                        svn lock -m 'lock & load' iota
>>                        """)
>> ]]]
>>
>
> No. :)
>
> [[[
> $ python
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> print """a\nb\nc"""
> a
> b
> c
>>>>
> ]]]
>
> I think triple quotes are mainly for
> - not having to escape ' and " characters
> - being able to imply \n by a real line break
>
> They still interpret \-escaped characters. (heh, is this users_at_python?)

That's right. But if you don't want to interpret \-escaped characters,
you can add an "r" in front of the quote. It's a useful feature. E.g.
r"a\nb\nc" or r"""a\nb\nc""".

Python 2.5.1 (r251:54863, May 18 2007, 16:56:43)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print r"a\nb\nc"
a\nb\nc
>>> print r"""
... echo "This represents a binary file\n" >> iota
... svn ci
... svn lock -m 'lock & load' iota
... """

 echo "This represents a binary file\n" >> iota
 svn ci
 svn lock -m 'lock & load' iota

>>>

Cheers,

David

------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=462&dsMessageId=2364000
Received on 2009-06-21 22:59:42 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.